tmux seems to override my default bash behavior. Suppose export someDir=/path/to/it, then in my shell

  1. Hitting tab on cd $someDir automatically adds a front slash, cd $someDir/. On tmux it does nothing, and prints $someDir (literally).
  2. Hitting tab on cd $someDir/ lists the contents. On tmux it expands the variable. Only two more tabs show the contents.

I have double checked both are running Bash, and if pertinent, this is my config:

set -g status-style bg=black
set -g status-style fg=red
set-window-option -g xterm-keys on
set -g terminal-overrides 'xterm*:smcup@:rmcup@'

How can I reproduce the original behavior?

More info

@Kusalananda's comment made me think that tmux might be overriding my completion settings. Hitting complete in a normal shell lists just 2 git wrappers. tmux shows a ton.

  • Are you sure that you are running the bash shell both in and outside tmux? – Kusalananda Sep 11 '18 at 7:12
  • @Kusalananda Good question - checked and yes. – kabanus Sep 11 '18 at 7:13

I'm not using tmux, but what I found (with horror) is that it's re-enabling the "programmable completion" of bash that I had long commented out in /etc/bash.bashrc -- thence the puzzling behavior you observed.

That's because tmux is exec'ing bash as a login shell (with argv[0] set to -bash) which is causing it to source /etc/profile and then /etc/profile.d/bash_completion.sh.

You have too options:

a) make the completion behavior the one you like in both login and non-login shells by editing .bash_profile and .bashrc

b) convince tmux not to run a login shell, eg. by

set -g default-command "/bin/bash"

in .tmux.conf

  • That is CRAZY. Are there any repercussions you are aware of? I found this, which seems to be no: superuser.com/questions/968942/… – kabanus Sep 11 '18 at 13:55
  • LOL. I'm using gnu screen, which does NOT start login shells by default. Neither does the terminal emulator (mlterm). Maybe I should check my head ;-) – mosvy Sep 11 '18 at 14:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.