diff options
| author | yuzu-eva <stevenhu@web.de> | 2022-08-22 22:48:02 +0200 |
|---|---|---|
| committer | yuzu-eva <stevenhu@web.de> | 2022-08-22 22:48:02 +0200 |
| commit | b2abf7439ed3c8097bccd3f71f3f5410552ac7fe (patch) | |
| tree | b650fd81505e6d015e490cebf0aa9b4f0dba68c5 /.config/nnn/plugins/.nnn-plugin-helper | |
| parent | 599e1315ce9be32944681ff4e88fc5afa8ae81b8 (diff) | |
switch from powerline to starship, added mpd & ncmpcpp configs. also using nnn now
Diffstat (limited to '.config/nnn/plugins/.nnn-plugin-helper')
| -rw-r--r-- | .config/nnn/plugins/.nnn-plugin-helper | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/.config/nnn/plugins/.nnn-plugin-helper b/.config/nnn/plugins/.nnn-plugin-helper new file mode 100644 index 0000000..a0377ac --- /dev/null +++ b/.config/nnn/plugins/.nnn-plugin-helper @@ -0,0 +1,38 @@ +#!/usr/bin/env sh + +# Description: Helper script for plugins +# +# Shell: POSIX compliant +# Author: Anna Arad + +selection=${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} +export selection + +## Set CUR_CTX to 1 to open directory in current context +CUR_CTX=0 +export CUR_CTX + +## Ask nnn to switch to directory $1 in context $2. +## If $2 is not provided, the function asks explicitly. +nnn_cd () { + dir="$1" + + if [ -z "$NNN_PIPE" ]; then + echo "No pipe file found" 1>&2 + return + fi + + if [ -n "$2" ]; then + context=$2 + elif [ $CUR_CTX -ne 1 ]; then + printf "Choose context 1-4 (blank for current): " + read -r context + fi + + printf "%s" "${context:-0}c$dir" > "$NNN_PIPE" +} + +cmd_exists () { + type "$1" > /dev/null 2>&1 + echo $? +} |
