From cdc4b9b3b6e092f827e2109aaf2d07b578ce4521 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 22 Dec 2020 20:22:52 +0300 Subject: .bashrc: launch nnn automatically This is kinda nice, I think. --- %HOME%/.bashrc | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/%HOME%/.bashrc b/%HOME%/.bashrc index 701ee1d..57abd9b 100644 --- a/%HOME%/.bashrc +++ b/%HOME%/.bashrc @@ -111,12 +111,16 @@ ranger() { fi } +inside_nnn() { + [ -n "$NNNLVL" ] && [ "${NNNLVL:-0}" -ge 1 ] +} + # nnn: print selected paths. alias ncp="cat ${NNN_SEL:-${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.selection} | tr '\0' '\n'" # nnn: like quitcd.bash_zsh, but better. n() { - [ -n "$NNNLVL" ] && [ "${NNNLVL:-0}" -ge 1 ] && exit + inside_nnn && exit export NNN_TMPFILE="${XDG_CONFIG_HOME:-$HOME/.config}/nnn/.lastd" @@ -144,11 +148,19 @@ multiplexed() { test -n "$STY" -o -n "$TMUX" } +if multiplexed && ! inside_nnn && local_terminal; then + # Launch nnn automatically in tmux, except when I'm inside a ssh session. + command -v nnn &> /dev/null && exec nnn +fi + # tmux: start automatically. # https://unix.stackexchange.com/a/113768 if os_is_cygwin && local_terminal; then # Skip, as it's too slow for some reason. true -elif ! multiplexed && command -v tmux &> /dev/null; then +elif multiplexed; then + # Skip, we're already running a multiplexer. + true +elif command -v tmux &> /dev/null; then exec tmux fi -- cgit v1.2.3