From 3f31b4688a7a9d753d8c8a673b1870a56a81a2f7 Mon Sep 17 00:00:00 2001 From: Mathis Chenuet Date: Sun, 3 Nov 2019 11:43:41 +0800 Subject: port automatic_cd to fish --- examples/fish_automatic_cd.fish | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 examples/fish_automatic_cd.fish diff --git a/examples/fish_automatic_cd.fish b/examples/fish_automatic_cd.fish new file mode 100644 index 00000000..6c4d3536 --- /dev/null +++ b/examples/fish_automatic_cd.fish @@ -0,0 +1,5 @@ +# Note: funcsave save the alias in fish's config files, you do not need to copy +# this file anywhere, just execute it once + +alias ranger-cd 'ranger --choosedir=$HOME/.rangerdir; set RANGERDIR (cat $HOME/.rangerdir); cd $RANGERDIR' +funcsave ranger-cd -- cgit 1.4.1-2-gfad0 From 885b7a7f993bfe05011889fa5410d07ae4f77a00 Mon Sep 17 00:00:00 2001 From: Mathis Chenuet Date: Sun, 3 Nov 2019 12:02:07 +0800 Subject: add doc and binding --- examples/fish_automatic_cd.fish | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/examples/fish_automatic_cd.fish b/examples/fish_automatic_cd.fish index 6c4d3536..5e859463 100644 --- a/examples/fish_automatic_cd.fish +++ b/examples/fish_automatic_cd.fish @@ -1,5 +1,15 @@ +# Automatically change the directory in fish after closing ranger +# +# This is a fish alias to automatically change the directory to the last visited +# one after ranger quits. +# To undo the effect of this function, you can type "cd -" to return to the +# original directory. +# # Note: funcsave save the alias in fish's config files, you do not need to copy # this file anywhere, just execute it once alias ranger-cd 'ranger --choosedir=$HOME/.rangerdir; set RANGERDIR (cat $HOME/.rangerdir); cd $RANGERDIR' funcsave ranger-cd + +# To bind Ctrl-O to ranger-cd, save this in `~/.config/fish/config.fish`: +bind \co 'ranger-cd ; fish_prompt' -- cgit 1.4.1-2-gfad0 From 0e6f244e7ef3ea34e106ab877fe86056b6f7eb52 Mon Sep 17 00:00:00 2001 From: Mathis Chenuet Date: Fri, 8 Nov 2019 02:12:12 +0800 Subject: use function, cleanup file, proper repaint --- examples/fish_automatic_cd.fish | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/fish_automatic_cd.fish b/examples/fish_automatic_cd.fish index 5e859463..d097ddd1 100644 --- a/examples/fish_automatic_cd.fish +++ b/examples/fish_automatic_cd.fish @@ -8,8 +8,14 @@ # Note: funcsave save the alias in fish's config files, you do not need to copy # this file anywhere, just execute it once -alias ranger-cd 'ranger --choosedir=$HOME/.rangerdir; set RANGERDIR (cat $HOME/.rangerdir); cd $RANGERDIR' +function ranger-cd + set dir (mktemp -t ranger_cd.XXX) + ranger --choosedir=$dir + cd (cat $dir) $argv + rm $dir + commandline -f repaint +end funcsave ranger-cd # To bind Ctrl-O to ranger-cd, save this in `~/.config/fish/config.fish`: -bind \co 'ranger-cd ; fish_prompt' +bind \co ranger-cd -- cgit 1.4.1-2-gfad0