How to stop making tmux auto setting RBENV_VERSION - ruby

tmux is auto setting RBENV_VERSION when I start tmux...
Anyone know how to stop it?
Because it auto sets it, I need to do
$ export RBENV_VERSION
to unset it and make .ruby-version work. Thx.

tmux itself will never set (or unset) RBENV_VERSION of its own accord. You have some bit of configuration that is causing this.
My guess is that RBENV_VERSION was set when you started your tmux server and that is is now part of the tmux “global environment” (the base environment inherited by all the processes started by tmux). You can check this
tmux show-environment -g | grep RBENV
If it is present there, you can delete it with this command:
tmux set-environment -gu RBENV_VERSION
If you often find yourself starting tmux when RBENV_VERSION is already set (and you do not want it sent “inside” tmux), then you can add the above command to your ~/.tmux.conf file to make sure that it is cleared every time you start a server.
Another possibility is that it is part of your tmux “session environment”; this environment is “layered” atop the global environment to form the environment that is inherited by the processes started for new windows and panes in a session. You can check it with this command (run it inside the session, or add -t sessname to specify a session):
tmux show-environment | grep RBENV
If this is present, you can unset it in a similar way:
tmux set-environment -u RBENV_VERSION
Finally, if the variable is not present in either the global or session environments, then it is probably coming from something in your shell initialization files. By default, tmux starts login shells, so be sure to check the corresponding bits of shell configuration (e.g. .bash_profile, .bash_login, .profile, etc.) as well as any other bits of initialization.

Related

How can I use bash variables in .tmux.conf?

I'm trying to write my own .tmux.config file and have managed to get most of it working (the file is quite simple). The intention is to have a minicom session running on the right side, whilst simultaneously saving the communication into a file. There is one problem. I define a UART_LOGFILE_NAME variable in my .bashrc file and export it, however, tmux still returns invalid environment variable. Is there something I'm missing?
my .tmux.conf file looks somewhat like this:
new-session -s serial -n console
split-window -h -l 30%
send-keys "sudo minicom rasp.serial -C ${UART_LOGFILE_NAME}"
split-window -v -l 10%
I can't find anything relevant in tmux manual entry except for the GLOBAL AND SESSION ENVIRONMENT. Also, sice I'm using the send-keys command I thought that the .bash_profile and therefore .bashrc files have been sourced before the minicom is launched (I have already managed to get the minicom running without logging and all panes have the UART_LOGFILE_NAME variable correctly defined after when I run tmux without logging of minicom session).
Thank you for your help

tmux does not inherit $SHELL variable from shell launching tmux

After updating my /etc/shell file and typing a csh -s /usr/local/bin/zsh afterwards, I decided to quit and relaunch tmux with hope it will take account of my new $SHELL environment variable. Unfortunately, tmux still shows the old /bin/zsh after typing echo $SHELL.
How to tell tmux to inherit the $SHELL variable of the shell that launched it?
set-option -g default-shell "$SHELL_PATH"
in ~/.tmux.conf or /etc/tmux.conf. Works on arch.
You can reload the config file with : source-file e.g.
<C-b>: source-file ~/.tmux.conf
You would need to do it for every tmux instance. Otherwise you may restart
tmux with killall tmux; tmux
these commands will change the path of shell in tmux

Stop tmux new-session after opeing terminal each time

I am using tmux on Kubuntu 22.04.1 with ZSH terminal. I have oh-my-zsh with it.
I have enabled tmux plugin of oh-my-zsh.
STEPS TO REPRODUCE:
enable tmux plugin in oh-my-zsh.
copy-paste below code(I have this in my ~/.zshrc) in ~/.zshrc
export ZSH_TMUX_AUTOSTART=true # Automatically starts tmux (default: false)
export ZSH_TMUX_AUTOCONNECT=false # Automatically connect to a previous session if it exits (default: true)
export ZSH_TMUX_AUTOSTART_ONCE=true # Autostart only if tmux hasn't been started previously (default: true)
OBSERVED RESULT:
It keeps creating new-session everytime I open terminal with previous session running.
EXPECTED RESULT:
I want it to kill all session on closing terminal (Konsole application of Kubuntu)
But I don't want it to create new session every time I open terminal. Which means I want only one session(new) running when I open terminal after closing it without connecting to previous session.
How can I stop this?

bash-completion (from Homebrew) not completing variables on OSX

I use bash completion all the time to save typing. However there is an oddity I am unable to figure out how to fix on OSX.
If I install bash-completion using Homebrew (brew install bash-completion) and set it up in .bashrc, the tab key will no longer complete environment variables. Without this installed, environment variable completion works as expected.
For example, I have shortcuts for all my SSH accounts for clients... instead of typing ssh myuser#somecrazydomain.com I can just type ssh $SSHCRAZY which is much easier to remember.
Expected behavior: In the built-in bash in OSX I can type ssh $SSHC and hit tab and it completes to the full command as expected. This is what I want.
Observed behavior: In bash using the homebrew bash-completion additions, hitting tab has no effect for environment variables.
Note: All other extensions added by the bash-completion project are desired (git command completion, etc). I don't want to uninstall it, I just want it to also work with environment variables.
Thanks in advance for any help!
You might consider using an SSH config file (~/.ssh/config) to set up your SSH shortcuts instead of using environment variables. You could put into that file:
Host crazy
HostName somecrazydomain.com
User myuser
Then you can just type ssh crazy.
I guess bash-completion must have defined completion rule for ssh. So try add the -o bashdefault option in your .bashrc. For example, if complete -p ssh output like this:
# complete -p ssh
complete -F _func ssh
#
then you can add this to your .bashrc (or .bash_profile):
complete -F _func -o bashdefault ssh
or
eval "$(complete -p ssh | sed 's/ssh$/-o bashdefault ssh/')"

Make TMUX active whenever I start a new shell session on OSX

I'm trying to start tmux automatically whenever I open a new shell, just note I'm using iTerm on OSX, I've tried putting the following in my .bashrc file:
if [[ ! $TERM =~ screen ]]; then
exec tmux
fi
this doesn't work, though I've tested it on Ubuntu and it works just fine.
Any help appreciated.
with your codes, what happens if you start 10 terminals?
you can check the output of tmux list-sessions to decide if tmux has already started.
Turns out my .bashrc file wasn't loaded properly off the .bash_profile so I just had to move my scripts and settings to .bash_profile

Resources