fish: Add 'trim_trailing_slashes' function and bind it

master
Pierre Neidhardt 2017-02-22 15:30:21 +01:00
parent faf05f1915
commit ba12fbd8ca
2 changed files with 11 additions and 0 deletions

View File

@ -5,4 +5,5 @@ function fish_user_key_bindings
end
bind \el downcase-word
bind \cw trim_trailing_slashes
end

View File

@ -0,0 +1,10 @@
# This is useful for rsync when folders have slashes automatically appended to
# them (e.g. with fzf completion).
function trim_trailing_slashes --description "Trim trailing slashes of all commandline tokens"
set -l list (commandline -o)
commandline -r ""
for i in $list
commandline -i -- (string escape (string replace -r '/$' '' $i))
commandline -i -- ' '
end
end