
Hello all ... I am currently running Debian Buster and Bash shell. I have a few Host aliases defined in my ~/.ssh/config. Example: Host test-server. So when, in console, I type ... $ ssh tes ... and hit Tab, then auto-completion fills out ... $ ssh test-server When I try to do the same thing in a terminal (urxvt), tab completion does *not* work. The complete host alias has to be entered. *But* tab completion for ssh host aliases *does* work if entered within tmux running in the terminal. Any idea how I can get tab completion working for ssh host aliases in the terminal? -- Daniel Wayne Armstrong https://www.circuidipity.com <http://www.circuidipity.com> Accomplish the great task by a series of small acts. -- Lao Tzu

On Thursday, May 30 2019, Daniel Wayne Armstrong via talk wrote:
Hello all ... I am currently running Debian Buster and Bash shell. I have a few Host aliases defined in my ~/.ssh/config. Example: Host test-server. So when, in console, I type ...
$ ssh tes
... and hit Tab, then auto-completion fills out ...
$ ssh test-server
When I try to do the same thing in a terminal (urxvt), tab completion does *not* work. The complete host alias has to be entered.
*But* tab completion for ssh host aliases *does* work if entered within tmux running in the terminal.
Any idea how I can get tab completion working for ssh host aliases in the terminal?
What's the shell you're using on urxvt? If it's not Bash, then bash-completion won't load. Thanks, -- Sergio GPG key ID: 237A 54B1 0287 28BF 00EF 31F4 D0EB 7628 65FC 5E36 Please send encrypted e-mail if possible http://sergiodj.net/

Resolved the issue by adding ... source /etc/profile.d/bash_completion.sh ... to my ~/.bashrc, though I still don't know why it would auto-complete OK inside tmux. On Thu, May 30, 2019 at 4:24 PM Daniel Wayne Armstrong < daniel@circuidipity.com> wrote:
Hello all ... I am currently running Debian Buster and Bash shell. I have a few Host aliases defined in my ~/.ssh/config. Example: Host test-server. So when, in console, I type ...
$ ssh tes
... and hit Tab, then auto-completion fills out ...
$ ssh test-server
When I try to do the same thing in a terminal (urxvt), tab completion does *not* work. The complete host alias has to be entered.
*But* tab completion for ssh host aliases *does* work if entered within tmux running in the terminal.
Any idea how I can get tab completion working for ssh host aliases in the terminal?
-- Daniel Wayne Armstrong https://www.circuidipity.com <http://www.circuidipity.com> Accomplish the great task by a series of small acts. -- Lao Tzu
-- Daniel Wayne Armstrong https://www.circuidipity.com <http://www.circuidipity.com> Accomplish the great task by a series of small acts. -- Lao Tzu

I've had a very similar problem with ssh host tab completion - the primary difference seemed to be that it worked on Mac and not on Linux. (I never use console these days, so I couldn't tell you about that.) I solved it as you did - by a more specific call to the completion file(s) in by bashrc. Although I think I sourced the one specifically for SSH hosts. I can't remember if it was here (ie. TLUG) or somewhere else that I saw a conversation about the incredibly tortuous routing of Bash startup. It was months or even a couple years ago. Essentially, someone had attempted to map out the decision process behind what files got parsed when Bash started depending on all the little check-boxes: is it interactive, is it console, is it login, dozens of others. The flow chart created was enough to make a hardened system administrator cry. So the direct route - add what you want to the bashrc - is definitely preferred to trying to actually debug what happened. On Fri, 31 May 2019 at 11:02, Daniel Wayne Armstrong via talk < talk@gtalug.org> wrote:
Resolved the issue by adding ...
source /etc/profile.d/bash_completion.sh
... to my ~/.bashrc, though I still don't know why it would auto-complete OK inside tmux.
On Thu, May 30, 2019 at 4:24 PM Daniel Wayne Armstrong < daniel@circuidipity.com> wrote:
Hello all ... I am currently running Debian Buster and Bash shell. I have a few Host aliases defined in my ~/.ssh/config. Example: Host test-server. So when, in console, I type ...
$ ssh tes
... and hit Tab, then auto-completion fills out ...
$ ssh test-server
When I try to do the same thing in a terminal (urxvt), tab completion does *not* work. The complete host alias has to be entered.
*But* tab completion for ssh host aliases *does* work if entered within tmux running in the terminal.
Any idea how I can get tab completion working for ssh host aliases in the terminal?
-- Daniel Wayne Armstrong https://www.circuidipity.com <http://www.circuidipity.com> Accomplish the great task by a series of small acts. -- Lao Tzu
-- Daniel Wayne Armstrong https://www.circuidipity.com <http://www.circuidipity.com> Accomplish the great task by a series of small acts. -- Lao Tzu
--- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk
-- Giles https://www.gilesorr.com/ gilesorr@gmail.com

I suspect you have indeed run into the difference between: Interactive Login shell Interactive Non-Login shell Non-Interactive Login shell Non-Interactive Non-Login shell .bashrc is called in almost all cases, .bash_profile only in some and bash completions likely only in some. TMUX is lunching another shell that may be non-login shell / non-interactive. So the question is why load completions, if it's not a person the shell is responding to. When I was learning about this I started adding checks like these: *** # .bashrc if [[ $- = *i* ]]; then echo 'Interactivity!' fi if shopt -q login_shell ; then echo 'Logged In!' fi *** # .bash_profile echo ".bash_profile executed!" *** https://unix.stackexchange.com/questions/38175/difference-between-login-shel... On 5/31/19 4:54 PM, Giles Orr via talk wrote:
I've had a very similar problem with ssh host tab completion - the primary difference seemed to be that it worked on Mac and not on Linux. (I never use console these days, so I couldn't tell you about that.) I solved it as you did - by a more specific call to the completion file(s) in by bashrc. Although I think I sourced the one specifically for SSH hosts.
I can't remember if it was here (ie. TLUG) or somewhere else that I saw a conversation about the incredibly tortuous routing of Bash startup. It was months or even a couple years ago. Essentially, someone had attempted to map out the decision process behind what files got parsed when Bash started depending on all the little check-boxes: is it interactive, is it console, is it login, dozens of others. The flow chart created was enough to make a hardened system administrator cry. So the direct route - add what you want to the bashrc - is definitely preferred to trying to actually debug what happened.
On Fri, 31 May 2019 at 11:02, Daniel Wayne Armstrong via talk <talk@gtalug.org <mailto:talk@gtalug.org>> wrote:
Resolved the issue by adding ...
source /etc/profile.d/bash_completion.sh
... to my ~/.bashrc, though I still don't know why it would auto-complete OK inside tmux.
On Thu, May 30, 2019 at 4:24 PM Daniel Wayne Armstrong <daniel@circuidipity.com <mailto:daniel@circuidipity.com>> wrote:
Hello all ... I am currently running Debian Buster and Bash shell. I have a few Host aliases defined in my ~/.ssh/config. Example: Host test-server. So when, in console, I type ...
$ ssh tes
... and hit Tab, then auto-completion fills out ...
$ ssh test-server
When I try to do the same thing in a terminal (urxvt), tab completion does *not* work. The complete host alias has to be entered.
*But* tab completion for ssh host aliases *does* work if entered within tmux running in the terminal.
Any idea how I can get tab completion working for ssh host aliases in the terminal?
-- Daniel Wayne Armstrong https://www.circuidipity.com <http://www.circuidipity.com> Accomplish the great task by a series of small acts. -- Lao Tzu
-- Daniel Wayne Armstrong https://www.circuidipity.com <http://www.circuidipity.com> Accomplish the great task by a series of small acts. -- Lao Tzu
--- Talk Mailing List talk@gtalug.org <mailto:talk@gtalug.org> https://gtalug.org/mailman/listinfo/talk
-- Giles https://www.gilesorr.com/ gilesorr@gmail.com <mailto:gilesorr@gmail.com>
--- Talk Mailing List talk@gtalug.org https://gtalug.org/mailman/listinfo/talk
-- Scott Sullivan

| From: Scott Sullivan via talk <talk@gtalug.org> | I suspect you have indeed run into the difference between: | | Interactive Login shell | Interactive Non-Login shell | Non-Interactive Login shell | Non-Interactive Non-Login shell | | .bashrc is called in almost all cases, .bash_profile only in some and bash | completions likely only in some. TMUX is lunching another shell that may be | non-login shell / non-interactive. So the question is why load completions, if | it's not a person the shell is responding to. This is certainly arcane but important knowledge. It is spelled out precisely in the bash manpage in section "INVOCATION". Too bad it is so complicated. Luckily INVOCATION is near the start of that manpage. That manpage doesn't capture the additional "features" of the default config files installed by my distro, Fedora. Your distro might well be different. The rules are heuristics. They attempt to capture this idea: A login shell sets up the environment for itself and to be inherited by its descendants. Other interactive shells will run ~/.bashrc if it exists. That is intended to set up the environment for this shell and not its descendants. The logic that implements this: An interactive login shell (or noninteractive shell with --login option) runs: /etc/profile then the FIRST of these that exists and is readable: ~/.bash_profile ~/.bash_login ~/.profile [The ~/.bash_profile takes precedence over ~/.profile because the ~/.profile was originally for the Bourne Shell and might not be tailored for bash. I don't know why .bash_profile and .bash_login are both supported.] An interactive non-login shell runs: ~/.bashrc [I don't understand why this isn't run for an interactive login shell. On my system, the default .bash_profile does run ~/.bashrc if it exists and is readable.] [On my system the default ~/.bashrc will run /etc/bashrc if it exists, not something documented in bash(1).] non-interactive non-login shell: nothing, unless BASH_ENV is set: if [ -n "$BASH_ENV" ]; then . "$BASH_ENV"; fi [On my system, BASH_ENV is set to /usr/share/Modules/init/bash which is a 134-line script!] If bash is invoked with the name "sh" it behaves differently. It tries to mimic what the Bourne Shell would have done. Summary: a fairly simple idea has become encrusted with well-meaning complexity. It isn't magic, but may take some time to spelunk it on your particular system. I don't know whether different distros are consistent. I don't know what tmux does to invoke a shell. You could probable experiment to find that out. ps -f -q $$ should tell you how tmux invoked this shell.
participants (5)
-
D. Hugh Redelmeier
-
Daniel Wayne Armstrong
-
Giles Orr
-
Scott Sullivan
-
Sergio Durigan Junior