aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/getplugs
diff options
context:
space:
mode:
authorGravatar Anna Arad <4895022+annagrram@users.noreply.github.com>2019-10-23 13:04:12 +0300
committerGravatar Mischievous Meerkat <engineerarun@gmail.com>2019-10-23 15:34:12 +0530
commit9afd7cf3bf8badb7e704fb1e1fbdb8031572c722 (patch)
tree90669833f994bfcff8b8f9edc0b044f2ea2f2e89 /plugins/getplugs
parent0144f440609b4fb7dcdf9e3325e6d1de3e6085bf (diff)
downloadnnn-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/getplugs')
-rwxr-xr-xplugins/getplugs24
1 files changed, 18 insertions, 6 deletions
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