summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorSean Whitton <spwhitton@spwhitton.name>2022-06-20 10:15:41 -0700
committerSean Whitton <spwhitton@spwhitton.name>2022-06-20 17:52:47 -0700
commitf9e9d3cd4d158f5756ea45aabe02cb998d85ec34 (patch)
tree71a313f3aa826aae7890cacc379247c6569b2a72 /bin
parentbb18ee1105e806f119509d73acb37de82c194a0d (diff)
downloaddotfiles-f9e9d3cd4d158f5756ea45aabe02cb998d85ec34.tar.gz
fix PATH for root tmux daemons launched by ii, ssh-and-tmux scripts
Diffstat (limited to 'bin')
-rwxr-xr-xbin/ii7
-rwxr-xr-xbin/ssh-and-tmux6
2 files changed, 10 insertions, 3 deletions
diff --git a/bin/ii b/bin/ii
index ac454eae..f77690a5 100755
--- a/bin/ii
+++ b/bin/ii
@@ -1,11 +1,14 @@
#!/bin/bash
-. $HOME/.shenv
-
if [ "$(hostname -f)" = "athena.silentflame.com" ]; then
# start irssi under tmux if it's not running
# we used to use dtach, but then dtach+mosh started to mispaint irssi
if ! tmux list-sessions | grep -Eq "^irssi:"; then
+ # If there's no root tmux daemon yet, ensure it has a normal PATH.
+ if tmux info >/dev/null 2>&1; then
+ source /etc/profile
+ source $HOME/.shenv
+ fi
# if I change timezone, patch the following line on 'athena'
# branch of dotfiles repo; e.g. `TZ=Asia/Taipei`. Then in
# running session, do e.g. /script exec $ENV{'TZ'}='Asia/Taipei';
diff --git a/bin/ssh-and-tmux b/bin/ssh-and-tmux
index 87ace865..6f1d482e 100755
--- a/bin/ssh-and-tmux
+++ b/bin/ssh-and-tmux
@@ -24,7 +24,11 @@ done
host="$1"
session="${2:-default}"
-cmd="tmux new-session -A -c \$HOME -s $session"
+# Go via a login shell such that if there is no root tmux daemon yet, it ends
+# up with a PATH as though the first tmux session were launched from an
+# interactive shell. This affects launching programs directly from tmux
+# (e.g. my C-\ e binding) for *all* sessions.
+cmd="\$SHELL -l -c \"tmux new-session -A -c \$HOME -s $session\""
if [ -n "$container_name" ]; then
display_host="$container_name"
cmd="$(printf "$container_cmd" "$container_name") -- $cmd"