From 9afd7cf3bf8badb7e704fb1e1fbdb8031572c722 Mon Sep 17 00:00:00 2001 From: Anna Arad <4895022+annagrram@users.noreply.github.com> Date: Wed, 23 Oct 2019 13:04:12 +0300 Subject: 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 --- plugins/getplugs | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'plugins/getplugs') diff --git a/plugins/getplugs b/plugins/getplugs index e144be3..42d5400 100755 --- a/plugins/getplugs +++ b/plugins/getplugs @@ -8,15 +8,27 @@ CONFIG_DIR=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/ PLUGIN_DIR=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/plugins +is_cmd_exists () { + which "$1" > /dev/null 2>&1 + echo $? +} + +if [ "$(is_cmd_exists sudo)" == "0" ]; then + sucmd=sudo +elif [ "$(is_cmd_exists doas)" == "0" ]; then + sucmd=doas +else + sucmd=: # noop +fi + # backup any earlier plugins if [ -d $PLUGIN_DIR ]; then - tar -C $CONFIG_DIR -cf $CONFIG_DIR"plugins-$(date '+%Y%m%d%H%M').tar.bz2" plugins/ + tar -C $CONFIG_DIR -czf $CONFIG_DIR"plugins-$(date '+%Y%m%d%H%M').tar.gz" plugins/ fi -mkdir -p $PLUGIN_DIR -cd $PLUGIN_DIR +cd $CONFIG_DIR curl -Ls -O https://github.com/jarun/nnn/archive/master.tar.gz -tar -xf master.tar.gz -cp -vf nnn-master/plugins/* . -sudo mv -vf nnn-master/misc/nlaunch/nlaunch /usr/local/bin/ +tar -zxf master.tar.gz +cp -vRf nnn-master/plugins . +$sucmd mv -vf nnn-master/misc/nlaunch/nlaunch /usr/local/bin/ rm -rf nnn-master/ master.tar.gz README.md -- cgit v1.2.3-70-g09d2