fish: add edit function to use EDITOR dynamically

This commit is contained in:
Charles Gould 2022-11-16 10:55:49 -05:00
parent 11be99c4a3
commit 824cac6b25
3 changed files with 10 additions and 3 deletions

View File

@ -27,8 +27,7 @@ function __fzf_files
end end
switch $key switch $key
case ctrl-e case ctrl-e
set -q EDITOR; or set EDITOR vim commandline -r "edit $file"
commandline -r "$EDITOR $file"
case '*' case '*'
commandline -i $file commandline -i $file
end end

View File

@ -57,7 +57,7 @@ if not set -q __universals_initialized
# Abbreviations # Abbreviations
abbr -a -U d 'docker' abbr -a -U d 'docker'
abbr -a -U e $EDITOR abbr -a -U e 'edit'
abbr -a -U h 'history' abbr -a -U h 'history'
abbr -a -U k 'kubectl' abbr -a -U k 'kubectl'
abbr -a -U l 'less' abbr -a -U l 'less'

View File

@ -0,0 +1,8 @@
function edit
if set -q EDITOR
$EDITOR $argv
else
printf (set_color red)"warning: EDITOR was not set, using vim as fallback\n"(set_color normal)
vim $argv
end
end