-
Notifications
You must be signed in to change notification settings - Fork 0
/
usercmd.zsh
59 lines (45 loc) · 2.23 KB
/
usercmd.zsh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#!/bin/zsh
function print_help() {
echo "alias \"esync\", \"esyncstatus\" and \"killesync\" do not exist on system"
echo "using vanilla commands"
if [ -f "$HOME/bin/kill_evince_synctex.zsh" ]; then
echo "please create the following file : $HOME/bin/kill_evince_synctex.zsh"
echo "with the following content :"
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "-"
echo 'code'
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "-"
echo '
source \$HOME/.custom/utils/colors.zsh
echo "\${YELLOW}evince sync running shellscripts\${NOCOLOR}"
for PID in \$(pgrep -f "evince_synctex.zsh"); do COMMAND=\$(ps -p \$PID -o comm=); echo "Running command for PID \$PID (\$COMMAND)"; done
echo "\${YELLOW}evince sync running dbus-monitor\${NOCOLOR}"
for PID in \$(pgrep -f dbus-monitor\ type=signal\,interface=org.gnome.evince.Window\,member=SyncSource); do COMMAND=\$(ps -p \$PID -o comm=); echo "Running command for PID \$PID (\$COMMAND)"; done
echo "\${YELLOW}Killing theses tasks\${NOCOLOR}"
for PID in \$(pgrep -f "evince_synctex.zsh"); do COMMAND=\$(ps -p \$PID -o comm=); echo "Killing command for PID \$PID (\$COMMAND)"; kill \$PID; done
for PID in \$(pgrep -f dbus-monitor\ type=signal\,interface=org.gnome.evince.Window\,member=SyncSource); do COMMAND=\$(ps -p \$PID -o comm=); echo "Killing command for PID \$PID (\$COMMAND)"; kill \$PID; done
'
printf '%*s\n' "${COLUMNS:-$(tput cols)}" '' | tr ' ' "-"
fi
if [ ! -f "$HOME/bin/evince_synctex.zsh" ]; then
echo 'download the following file :
> https://github.com/Vinno97/evince-synctex/
and put it in $HOME/bin/evince_synctex.zsh"'
fi
echo 'please add the following aliases :'
echo '
alias esync="$HOME/bin/evince_synctex.zsh listen code --goto %f:%l > /dev/null 2>&1 &"
alias killesync="ps aux | grep evince_synctex | grep -v grep"
alias esyncstatus="zsh $HOME/bin/kill_evince_synctex.zsh"
'
}
# $ SCRIPT
if [[ -z "$(command -v esync)" && -z "$(command -v esyncstatus)" && -z "$(command -v killesync)" ]]; then
echo "alias \"esync\", \"esyncstatus\" and \"killesync\" exist on system"
if [ -z $(command esyncstatus) ]; then
command esync
else
command killesync
fi
else
# print_help
fi