diff options
author | Anna Arad <4895022+annagrram@users.noreply.github.com> | 2019-10-23 13:04:12 +0300 |
---|---|---|
committer | Mischievous Meerkat <engineerarun@gmail.com> | 2019-10-23 15:34:12 +0530 |
commit | 9afd7cf3bf8badb7e704fb1e1fbdb8031572c722 (patch) | |
tree | 90669833f994bfcff8b8f9edc0b044f2ea2f2e89 /plugins/fzcd | |
parent | 0144f440609b4fb7dcdf9e3325e6d1de3e6085bf (diff) | |
download | nnn-9afd7cf3bf8badb7e704fb1e1fbdb8031572c722.tar.gz |
Implement plugins control of nnn + plugins (#364)
* Implement plugins control of nnn + plugins
* Refactor plugins control code and fix getplugs to recognize hidden files
* Fix bug when going to dir on non-current context from plugin
* Fix some plugins to work on openbsd and freebsd
* Renamings
* Switch to -R flag in cp instead of -r; BSDs complain
* Change braces of function location
* Rewrite plugin creation in README and add new plugins to the table
* Update the fzcd script to include fzy or fzf
* Change plugin name resolve-link-dir -> lncd
* Fixing plugins README table
* Remove some cd plugins but add them as examples to plugins README
Diffstat (limited to 'plugins/fzcd')
-rwxr-xr-x | plugins/fzcd | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/plugins/fzcd b/plugins/fzcd new file mode 100755 index 0000000..443ac2d --- /dev/null +++ b/plugins/fzcd @@ -0,0 +1,32 @@ +#!/usr/bin/env sh + +# Description: Run fzf and go to the directory of the file selected +# +# Shell: POSIX compliant +# Author: Anna Arad + +. $(dirname $0)/.nnn-plugin-helper + +if [ "$(cmd_exists fzy)" -eq "0" ]; then + if [ "$(cmd_exists fd)" -eq "0" ]; then + fd=fd + elif [ "$(cmd_exists fdfind)" -eq "0" ]; then + fd=fdfind + else + fd=find + fi + + sel=$($fd | fzy) +elif [ "$(cmd_exists fzf)" -eq "0" ]; then + sel=$(fzf --print0) +else + exit 1 +fi + +if [ "$?" -eq "0" ]; then + case "$(file -bi "$sel")" in + *directory*) ;; + *) sel=$(dirname $sel) ;; + esac + nnn_cd "$PWD/$sel" +fi |