From 5a847657dce538e0f4eeb462638d9ff9fbfccd1c Mon Sep 17 00:00:00 2001 From: cswimr Date: Tue, 22 Oct 2024 13:57:37 -0400 Subject: [PATCH] I LOVE NNN --- .zshc/completion/nnn.zsh | 49 ++++++++++++++++++++++++++++++++++++++++ .zshc/func.zsh | 0 .zshc/nnn.zsh | 30 ++++++++++++++++++++++++ 3 files changed, 79 insertions(+) create mode 100755 .zshc/completion/nnn.zsh mode change 100644 => 100755 .zshc/func.zsh create mode 100755 .zshc/nnn.zsh diff --git a/.zshc/completion/nnn.zsh b/.zshc/completion/nnn.zsh new file mode 100755 index 0000000..3fd2391 --- /dev/null +++ b/.zshc/completion/nnn.zsh @@ -0,0 +1,49 @@ +#compdef nnn +# +# Completion definition for nnn. +# +# Author: +# Arun Prakash Jana +# + +setopt localoptions noshwordsplit noksharrays +local -a args +args=( + '(-a)-a[auto-create NNN_FIFO]' + '(-A)-A[disable dir auto-enter]' + '(-b)-b[bookmark key to open]:key char' + '(-B)-B[use bsdtar for archives]' + '(-c)-c[cli-only opener]' + '(-C)-C[color by context]' + '(-d)-d[start in detail mode]' + '(-D)-D[dirs in context color]' + '(-e)-e[open text files in $VISUAL/$EDITOR/vi]' + '(-E)-E[use EDITOR for undetached edits]' + '(-f)-f[use readline history file]' + '(-F)-F[fifo notification mode]:mode:(( 0\:"notify as previewer" 1\:"notify as explorer" ))' + '(-g)-g[regex filters]' + '(-H)-H[show hidden files]' + '(-i)-i[show current file info]' + '(-J)-J[no auto-advance on selection]' + '(-K)-K[detect key collision and exit]' + '(-l)-l[lines to move per scroll]:val' + '(-n)-n[start in type-to-nav mode]' + '(-o)-o[open files only on Enter]' + '(-p)-p[copy selection to file]:file name' + '(-P)-P[plugin key to run]:key char' + '(-Q)-Q[disable quit confirmation]' + '(-r)-r[show cp, mv progress (Linux-only)]' + '(-R)-R[disable rollover at edges]' + '(-s)-s[load session]:session name' + '(-S)-S[persistent session]' + '(-t)-t[timeout to lock]:seconds' + '(-T)-T[sort order]:key:(( a\:"apparent disk usasge" d\:"disk usage" e\:"extension" r\:"reverse" s\:"size" t\:"time" v\:"version" ))' + '(-u)-u[use selection (no prompt)]' + '(-U)-U[show user and group]' + '(-V)-V[show program version and exit]' + '(-x)-x[notis, sel to system clipboard, xterm title]' + '(-0)-0[use null separator in picker mode]' + '(-h)-h[show program help]' + '*:filename:_files' +) +_arguments -S -s $args diff --git a/.zshc/func.zsh b/.zshc/func.zsh old mode 100644 new mode 100755 diff --git a/.zshc/nnn.zsh b/.zshc/nnn.zsh new file mode 100755 index 0000000..944442c --- /dev/null +++ b/.zshc/nnn.zsh @@ -0,0 +1,30 @@ +nnn n () +{ + # Block nesting of nnn in subshells + [ "${NNNLVL:-0}" -eq 0 ] || { + echo "nnn is already running" + return + } + + # The behaviour is set to cd on quit (nnn checks if NNN_TMPFILE is set) + # If NNN_TMPFILE is set to a custom path, it must be exported for nnn to + # see. To cd on quit only on ^G, remove the "export" and make sure not to + # use a custom path, i.e. set NNN_TMPFILE *exactly* as follows: + # NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" + export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" + + # Unmask ^Q (, ^V etc.) (if required, see `stty -a`) to Quit nnn + # stty start undef + # stty stop undef + # stty lwrap undef + # stty lnext undef + + # The command builtin allows one to alias nnn to n, if desired, without + # making an infinitely recursive alias + command nnn -e "$@" + + [ ! -f "$NNN_TMPFILE" ] || { + . "$NNN_TMPFILE" + rm -f -- "$NNN_TMPFILE" > /dev/null + } +}