forked from graahnul-grom/fzf-csh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fzf-csh.csh
68 lines (54 loc) · 1.56 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
# fzf-csh: C shell (csh) history support for fzf
#
# home page: https://github.com/graahnul-grom/fzf-csh
# copyright (c) 2022 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"
if ( ! -X $FILE_IMPL ) then
echo "fzf-csh: could not find ${FILE_IMPL}."
echo " make sure it's in the PATH and is executable."
unset DIR_OUT
unset FILE_CMD
unset FILE_IMPL
exit 1
endif
set KEY_RUN = "^R"
set KEY_1 = "^X^A^B^C^D^E"
set KEY_2 = "^X^F^G^H^I^J"
bindkey -c $KEY_1 "history -h | ${FILE_IMPL} ${FILE_CMD} && source ${FILE_CMD}; \
rm -f ${FILE_CMD}"
bindkey -s $KEY_RUN "${KEY_1}${KEY_2}"
unset DIR_OUT
unset FILE_CMD
unset FILE_IMPL
unset KEY_RUN
unset KEY_1
unset KEY_2