Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use tmux's default-shell opt to get preffered SHELL for default-command in OSX #75

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Use tmux's default-shell opt to get preffered SHELL for `default-co…
…mmand` in OSX

tmux-sensible modified `default-command` for OSX to use
`reattach-to-user-namespace` when creating shell with user
preffered shell type from `SHELL` environment variable for circumventing
OSX's process namespace segregation.
Prior to tmux 3.5 this `SHELL` environment variable was not modified by Tmux
when running a shell command with tmux's default `sh` shell, so this
worked fine.
Now from tmux 3.5 `SHELL` environment variable is set to `sh`, this
causes tmux to load `sh` shell when executing default-command instead of
user preffered shell when using tmux-sensible plugin.
  • Loading branch information
venlinz committed Nov 17, 2024
commit 2f3ee2a692a9125e7ef48580357d6e048fc95bb3
7 changes: 6 additions & 1 deletion sensible.tmux
Original file line number Diff line number Diff line change
@@ -37,6 +37,11 @@ option_value_not_changed() {
[ "$option_value" == "$default_value" ]
}

get_server_option_value() {
local option="$1"
tmux show-options -gv "$option"
}

server_option_value_not_changed() {
local option="$1"
local default_value="$2"
@@ -100,7 +105,7 @@ main() {

# required (only) on OS X
if is_osx && command_exists "reattach-to-user-namespace" && option_value_not_changed "default-command" ""; then
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the reattach-to-user-namespace documentation, this command is no longer necessary after Tmux 2.6 so I think it would be great if you could change the condition to only set the default-command based on the version of tmux

ChrisJohnsen/tmux-MacOSX-pasteboard@77b3004

tmux set-option -g default-command "reattach-to-user-namespace -l $SHELL"
tmux set-option -g default-command "reattach-to-user-namespace -l $(get_server_option_value 'default-shell')"
fi

# upgrade $TERM, tmux 1.9