-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtigrc_extension
73 lines (64 loc) · 2.92 KB
/
tigrc_extension
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# xmf - run the selected Makefile target
bind generic xmf !sh -c 'if [ -f \"%(directory)/Makefile\" ]; then \
make "$($ZSH_TIG_DIR/scripts/make-real-targets "%(directory)/Makefile" | \
{ command -v fzf >/dev/null && { fzf; true; } || \
{ command -v fzy >/dev/null && { fzy; true; } } })"; \
else \
echo No Makefile found; \
fi'
# xamf - run make all
bind generic xamf !sh -c 'if [ -f \"%(directory)/Makefile\" ]; then \
make all; \
else \
echo No Makefile found; \
fi'
# xcmf - run make clean
bind generic xcmf !sh -c 'if [ -f \"%(directory)/Makefile\" ]; then \
make clean; \
else \
echo No Makefile found; \
fi'
# xcp - copy the selected SHA into clipboard
bind generic xcp +sh -c "OKMESSAGE='The Commit SHA Copied Into Cliboard'; \
[ '%(commit)' = 0000000000000000000000000000000000000000 ] && { \
echo 'Please select a commit first'; true; } || \
printf '%s' %(commit) | { \
command -v pbcopy >/dev/null && { pbcopy && \
echo \$OKMESSAGE; true; } || \
{ command -v xsel >/dev/null && \ { xsel -ib && \
echo \$OKMESSAGE; true; } || \
{ command -v xclip >/dev/null && { xclip -selection clipboard && \
echo \$OKMESSAGE; true; } || \
{ echo 'No clipboard tool found'; cat >/dev/null; } } } }"
# xfcp - copy the selected file into clipboard
bind generic xfcp +sh -c "OKMESSAGE='File Contents Copied Into The Cliboard'; \
[ -z '%(file)' ] && { \
echo 'Please select a file first (e.g.: in the stage view)'; true; } || \
cat %(file) | { \
command -v pbcopy >/dev/null && { pbcopy && \
echo \$OKMESSAGE; true; } || \
{ command -v xsel >/dev/null && \ { xsel -ib && \
echo \$OKMESSAGE; true; } || \
{ command -v xclip >/dev/null && { xclip -selection clipboard && \
echo \$OKMESSAGE; true; } || \
{ echo 'No clipboard tool found'; cat >/dev/null; } } } }"
# xmc – run Midnight Commander
bind generic xmc !sh -c 'mc %(directory) ${ZSH_TIG_MC_DIR:-$HOME}'
# xhmc – run Midnight Commander in home directory (right pane)
bind generic xhmc !sh -c 'mc %(directory) $HOME'
# xed - run editor on the selected file
bind generic xed !sh -c '[ -z "%(file)" ] && \
{ echo "Please select a file first, or use xled binding"; true; } || \
${VISUAL:-${EDITOR:-vim}} %(file)'
# xled - run editor through a fuzzy finder
bind generic xled !sh -c '\
{ command -v fzf >/dev/null && { \
${VISUAL:-${EDITOR:-vim}} \
"$(find | egrep -v "^\\./\\.(git|_zplugin)" | \
sed -e "s/^\\.\\///" | fzf)"; true; } || \
{ command -v fzy >/dev/null && { \
${VISUAL:-${EDITOR:-vim}} \
"$(find | egrep -v "^\\./\\.(git|_zplugin)" | \
sed -e "s/^\\.\\///" | fzy)"; \
true; } } };'
# vim:ft=config:sw=4:sts=4:et