aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/%HOME%
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2020-12-22 20:22:52 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2020-12-23 08:24:47 +0300
commitcdc4b9b3b6e092f827e2109aaf2d07b578ce4521 (patch)
tree7710c5ac3e9279841f83a54d068414cfcf638d7c /%HOME%
parenttmux: don't autostart on Cygwin (diff)
downloadlinux-home-cdc4b9b3b6e092f827e2109aaf2d07b578ce4521.tar.gz
linux-home-cdc4b9b3b6e092f827e2109aaf2d07b578ce4521.zip
.bashrc: launch nnn automatically
This is kinda nice, I think.
Diffstat (limited to '')
-rw-r--r--%HOME%/.bashrc16
1 files 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