From 2fd57e8772db6c2775757118bf9e521839631cdd Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Wed, 26 Feb 2020 15:26:00 -0500 Subject: add lf --- fish/.config/fish/completions/lf.fish | 11 +++++++++ .../fish/functions/fish_user_key_bindings.fish | 3 ++- fish/.config/fish/functions/is_git.fish | 3 +-- fish/.config/fish/functions/lfcd.fish | 27 ++++++++++++++++++++++ 4 files changed, 41 insertions(+), 3 deletions(-) create mode 100644 fish/.config/fish/completions/lf.fish create mode 100644 fish/.config/fish/functions/lfcd.fish (limited to 'fish/.config') diff --git a/fish/.config/fish/completions/lf.fish b/fish/.config/fish/completions/lf.fish new file mode 100644 index 0000000..9fb6ba9 --- /dev/null +++ b/fish/.config/fish/completions/lf.fish @@ -0,0 +1,11 @@ +complete -c lf -o command -r -d 'command to execute on client initialization' +complete -c lf -o cpuprofile -r -d 'path to the file to write the CPU profile' +complete -c lf -o doc -d 'show documentation' +complete -c lf -o last-dir-path -r -d 'path to the file to write the last dir on exit (to use for cd)' +complete -c lf -o memprofile -r -d 'path to the file to write the memory profile' +complete -c lf -o remote -x -d 'send remote command to server' +complete -c lf -o selection-path -r -d 'path to the file to write selected files on open (to use as open file dialog)' +complete -c lf -o server -d 'start server (automatic)' +complete -c lf -o version -d 'show version' +complete -c lf -o help -d 'show help' + diff --git a/fish/.config/fish/functions/fish_user_key_bindings.fish b/fish/.config/fish/functions/fish_user_key_bindings.fish index 350a9da..73037da 100644 --- a/fish/.config/fish/functions/fish_user_key_bindings.fish +++ b/fish/.config/fish/functions/fish_user_key_bindings.fish @@ -1,3 +1,4 @@ function fish_user_key_bindings - fzf_key_bindings + fzf_key_bindings + bind \co 'lfcd; commandline -f repaint' end diff --git a/fish/.config/fish/functions/is_git.fish b/fish/.config/fish/functions/is_git.fish index a0f3091..a8370f4 100644 --- a/fish/.config/fish/functions/is_git.fish +++ b/fish/.config/fish/functions/is_git.fish @@ -1,5 +1,4 @@ function is_git - git rev-parse --verify HEAD >/dev/null ^&1 - # keeping ^ for now for v2 backwards compatibility + git rev-parse --verify HEAD >/dev/null 2>&1 end diff --git a/fish/.config/fish/functions/lfcd.fish b/fish/.config/fish/functions/lfcd.fish new file mode 100644 index 0000000..4e8e041 --- /dev/null +++ b/fish/.config/fish/functions/lfcd.fish @@ -0,0 +1,27 @@ +function lfcd + set tmp (mktemp) + set fid (mktemp) + + lf -command '$printf $id > "'$fid'"' -last-dir-path=$tmp $argv + + set id (cat $fid) + set archivemount_dir "/tmp/__lf_archivemount_"$id + + if test -f "$archivemount_dir" + for line in (cat $archivemount_dir) + umount "$line" + rm -rf "$line" + end + end + + if test -f "$tmp" + set dir (cat $tmp) + rm -f "$tmp" + if test -d "$dir" + if test "$dir" != (pwd) + cd "$dir" + end + end + end +end + -- cgit 1.4.1