Aliases defined in .bash_aliases
and .bashrc
don't work in tmux
.
Can this be changed in some configuration, so the aliases work under tmux
?
(Chris Down's answer has the right explanation but not a good workaround)
Your problem stems from a combination of a bash design bug and a tmux design bug.
By default, tmux starts a login shell in every window. This doesn't make any sense: if you've set tmux as your login shell, you need to set the default-command
option to something other than tmux; and if you haven't set tmux as your login shell, you need to set the default-command
option to avoid starting a login shell inside tmux. So put the following in your ~/.tmux.conf
to tell tmux to start an ordinary shell:
set-option -g default-command $SHELL
Then your .bashrc
will be read. There is another issue with bash, which doesn't matter here if you configure tmux as recommended above, but which will surface again if you log in in text mode (on a text console, or over SSH). Bash reads ~/.bash_profile
in login shells, and ~/.bashrc
in interactive shells but only if they are not login shells. To read ~/.bashrc
also in login shells if they're interactive, add this to your ~/.bash_profile
:
case $- in *i*) . ~/.bashrc;; esac
tmux
launches a login shell by default, so ~/.bashrc
will not be executed (which then subsequently sources ~/.bash_aliases
. You need to source ~/.bashrc
from your ~/.bash_profile
. See the INVOCATION
section of man bash
.
tmux
? I use tmux about year and haven't seen any problems with aliases. Try to addset -x
at the begin of your.bashrc
and run intmux
commandsource ~/.bashrc
. May be you'll find any errors and it will solve your problem.