blob: 7b6e5e6ad576ae4743017c630500c3b1cb881228 (
plain)
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
|
function toggle-sudo
set buf (commandline)
if test -z "$buf"
set last (history | head -n1)
if test -z "$last"
commandline -r "sudo "
return
end
set buf $last
end
if string match -rq '^\s*sudo(\s+|$)' -- $buf
set new (string replace -r '^\s*sudo\s*' '' -- $buf)
if test -z "$new"
commandline -r ""
return
end
commandline -r $new
else
commandline -r "sudo $buf"
end
end
function fish_user_key_bindings
for m in default insert
bind -M $m ctrl-f accept-autosuggestion
bind -M $m ctrl-backspace backward-kill-word
end
for m in default insert normal
bind -M $m alt-left 'commandline -f cancel; cd -; commandline -f repaint'
bind -M $m alt-up 'commandline -f cancel; cd ..; commandline -f repaint'
bind -M $m ctrl-e toggle-sudo
bind -M $m ctrl-r history-pager
end
bind -M normal U redo
for m in default insert normal replace replace_one
bind --preset --erase -M $m ctrl-h
bind -M $m ctrl-h backward-char
bind --preset --erase -M $m ctrl-j
bind -M $m ctrl-j down-or-search
bind --preset --erase -M $m ctrl-k
bind -M $m ctrl-k up-or-search
# clear overrode
bind --preset --erase -M $m ctrl-l
bind -M $m ctrl-l forward-char
end
end
|