Browse Source

Allow choosing the same context in plugin helper

master
Arun Prakash Jana 5 years ago
parent
commit
9f1b51b004
No known key found for this signature in database GPG Key ID: A75979F35C080412
2 changed files with 6 additions and 2 deletions
  1. +5
    -1
      plugins/.nnn-plugin-helper
  2. +1
    -1
      plugins/README.md

+ 5
- 1
plugins/.nnn-plugin-helper View File

@@ -8,6 +8,10 @@
selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection selection=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection
export 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. ## Ask nnn to switch to directory $1 in context $2.
## If $2 is not provided, the function asks explicitly. ## If $2 is not provided, the function asks explicitly.
nnn_cd () { nnn_cd () {
@@ -20,7 +24,7 @@ nnn_cd () {


if [ -n "$2" ]; then if [ -n "$2" ]; then
context=$2 context=$2
else
elif [ $CUR_CTX -ne 1 ]; then
printf "Choose context 1-4 (blank for current): " printf "Choose context 1-4 (blank for current): "
read -r context read -r context
fi fi


+ 1
- 1
plugins/README.md View File

@@ -162,7 +162,7 @@ The plugin should write a single string in the format `<number><path>` without a
The number indicates the context to change the active directory of (0 is used to indicate the current context). The number indicates the context to change the active directory of (0 is used to indicate the current context).


For convenience, we provided a helper script named `.nnn-plugin-helper` and a function named `nnn_cd` to ease this process. `nnn_cd` receives the path to change to as the first argument, and the context as an optional second argument. For convenience, we provided a helper script named `.nnn-plugin-helper` and a function named `nnn_cd` to ease this process. `nnn_cd` receives the path to change to as the first argument, and the context as an optional second argument.
If a context is not provided, it is asked for explicitly.
If a context is not provided, it is asked for explicitly. To skip this and choose the current context, set the `CUR_CTX` variable in `.nnn-plugin-helper` to `1`.
Usage examples can be found in the Examples section below. Usage examples can be found in the Examples section below.


#### Examples #### Examples


Loading…
Cancel
Save