mirror of
https://github.com/jarun/nnn.git
synced 2024-09-12 00:57:19 +00:00
* Initial commit of sessions implementation * Reduce code duplication * Move load session to program flag -e * Fix context initialization problem when loading session * Add pinned directory to session and reduce session file size * Make load_session print an error if exists and few minor adjustments * Refactor session's file structure * Initialize required structures in load_session before loading * Add load session dynamically, restore last session, and extra fixes * Fix indentation * Add sessions documentation to man page * Update fish completions with sessions and make some improvements * Move to single keybinding session management and add help info * ESC when asked to insert session name behaves better * Add sessions completion for bash * Remove pinned dir from session and minor code refactors
48 lines
1,022 B
Bash
48 lines
1,022 B
Bash
#
|
|
# Rudimentary Bash completion definition for nnn.
|
|
#
|
|
# Author:
|
|
# Arun Prakash Jana <engineerarun@gmail.com>
|
|
#
|
|
|
|
_nnn () {
|
|
COMPREPLY=()
|
|
local IFS=$' \n'
|
|
local cur=$2 prev=$3
|
|
local -a opts
|
|
opts=(
|
|
-a
|
|
-b
|
|
-c
|
|
-d
|
|
-f
|
|
-H
|
|
-i
|
|
-K
|
|
-n
|
|
-o
|
|
-p
|
|
-r
|
|
-s
|
|
-S
|
|
-t
|
|
-v
|
|
-h
|
|
)
|
|
if [[ $prev == -b ]]; then
|
|
local bookmarks=$(echo $NNN_BMS | awk -F: -v RS=\; '{print $1}')
|
|
COMPREPLY=( $(compgen -W "$bookmarks" -- "$cur") )
|
|
elif [[ $prev == -p ]]; then
|
|
COMPREPLY=( $(compgen -f -d -- "$cur") )
|
|
elif [[ $prev == -e ]]; then
|
|
local sessions_dir=${XDG_CONFIG_HOME:-$HOME/.config}/nnn/sessions
|
|
COMPREPLY=( $(compgen -W "$(ls $sessions_dir)" -- "$cur") )
|
|
elif [[ $cur == -* ]]; then
|
|
COMPREPLY=( $(compgen -W "${opts[*]}" -- "$cur") )
|
|
else
|
|
COMPREPLY=( $(compgen -f -d -- "$cur") )
|
|
fi
|
|
}
|
|
|
|
complete -o filenames -F _nnn nnn
|