-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfzf-csh-impl.csh
executable file
·71 lines (59 loc) · 1.54 KB
/
fzf-csh-impl.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
#!/usr/bin/env csh
# fzf-csh: C shell (csh) history support for fzf
#
# home page: https://github.com/graahnul-grom/fzf-csh
# copyright (c) 2022 dmn <graahnul.grom@ya.ru>
# license: BSD2CLAUSE
# fzf home page: https://github.com/junegunn/fzf
#
if ( $#argv != 1 ) then
exit 1
endif
set FILE_CMD = $1
set KEY_AUX = "^X^F^G^H^I^J"
touch $FILE_CMD >& /dev/null
if ( $? != 0 ) then
echo "fzf-csh: unable to write to ${FILE_CMD}."
unset FILE_CMD
unset KEY_AUX
exit 1
endif
set ES_OLD = $echo_style
set echo_style = both
echo -n bindkey -s \"${KEY_AUX}\" >! $FILE_CMD
echo -n " " >> $FILE_CMD
set echo_style = $ES_OLD
unset ES_OLD
set HEIGHT = ""
if ( $?DISPLAY ) then
set HEIGHT = "--height=50%"
endif
fzf --tac --no-sort $HEIGHT | \
sed -E -e 's,\\,\\\\\\\\,g' \
-e 's, ,\\ ,g' \
-e "s,',\\',g" \
-e 's,",\\",g' \
-e 's,\$,\\$,g' \
-e 's,#,\\#,g' \
-e 's,`,\\`,g' \
-e 's,&,\\&,g' \
-e 's,\(,\\(,g' \
-e 's,\),\\),g' \
-e 's,~,\\~,g' \
-e 's,\[,\\[,g' \
-e 's,],\\],g' \
-e 's,\{,\\{,g' \
-e 's,\},\\},g' \
-e 's,<,\\<,g' \
-e 's,>,\\>,g' \
-e 's,\;,\\;,g' \
-e 's,\|,\\|,g' \
-e 's,\?,\\?,g' \
-e 's,\^,\\^,g' \
>> $FILE_CMD
if ( $? != 0 ) then
echo bindkey \"${KEY_AUX}\" backward-char >! $FILE_CMD
endif
unset FILE_CMD
unset KEY_AUX
unset HEIGHT