-
Notifications
You must be signed in to change notification settings - Fork 2
/
fzf-csh.csh
90 lines (72 loc) · 2.26 KB
/
fzf-csh.csh
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# fzf-csh: C shell (csh) history support for fzf
#
# home page: https://github.com/graahnul-grom/fzf-csh
# copyright (c) 2022-2023 dmn <[email protected]>
# license: BSD2CLAUSE
# fzf home page: https://github.com/junegunn/fzf
#
if ( ! -X "fzf" ) then
echo "fzf-csh: could not find fzf executable."
echo " make sure fzf is installed."
exit 1
endif
set DIR_OUT = $HOME
if ( $?FZF_CSH_TMP_DIR ) then
set DIR_OUT = $FZF_CSH_TMP_DIR
endif
test -e $DIR_OUT -a -d $DIR_OUT
if ( $? != 0 ) then
echo "fzf-csh: ${DIR_OUT} does not exist or not a directory."
unset DIR_OUT
exit 1
endif
test -w $DIR_OUT
if ( $? != 0 ) then
echo "fzf-csh: unable to write to ${DIR_OUT}."
echo " make sure the directory is writable, or set the"
echo ' $FZF_CSH_TMP_DIR environment variable to point'
echo " to some writable directory before sourcing the"
echo " fzf-csh.csh file."
unset DIR_OUT
exit 1
endif
set FILE_CMD = "${DIR_OUT}/fzf-csh-cmd.tmp"
set FILE_IMPL = "fzf-csh-impl.csh"
set FILE_IMPL_FIND = "fzf-csh-find.sh"
if ( ! -X $FILE_IMPL ) then
echo "fzf-csh: could not find ${FILE_IMPL}."
echo " make sure it's in the PATH and has executable bit set (chmod +x)."
unset DIR_OUT
unset FILE_CMD
unset FILE_IMPL
unset FILE_IMPL_FIND
exit 1
endif
if ( ! -X $FILE_IMPL_FIND ) then
echo "fzf-csh: could not find ${FILE_IMPL_FIND}."
echo " make sure it's in the PATH and has executable bit set (chmod +x)."
unset DIR_OUT
unset FILE_CMD
unset FILE_IMPL
unset FILE_IMPL_FIND
exit 1
endif
set KEY_HISTORY = "^R"
set KEY_HISTORY_AUX = "^X^A^B^C^D^E"
set KEY_AUX = "^X^F^G^H^I^J"
bindkey -c $KEY_HISTORY_AUX "history -h | ${FILE_IMPL} ${FILE_CMD} && source ${FILE_CMD}; \
rm -f ${FILE_CMD}"
bindkey -s $KEY_HISTORY "${KEY_HISTORY_AUX}${KEY_AUX}"
set KEY_FILES = "^T"
set KEY_FILES_AUX = "^X^K^L^M^N^O"
bindkey -c $KEY_FILES_AUX "${FILE_IMPL_FIND} | ${FILE_IMPL} ${FILE_CMD} && source ${FILE_CMD}; \
rm -f ${FILE_CMD}"
bindkey -s $KEY_FILES "${KEY_FILES_AUX}${KEY_AUX}"
unset DIR_OUT
unset FILE_CMD
unset FILE_IMPL
unset KEY_HISTORY
unset KEY_HISTORY_AUX
unset KEY_FILES
unset KEY_FILES_AUX
unset KEY_AUX