Hi. I have bash 5.2.15(1). When I cd into an empty directory, and type "cd <tab><tab>", the shell offers 178 possibilities. If I restrict it to an initial letter and hit <tab> once, I think the spurious offerings are from $HOME. How can I make it not do that and only offer me things I ask for?
On Sat, Sep 07, 2024 at 08:56:08 -0400, Eben King wrote:
Hi. I have bash 5.2.15(1). When I cd into an empty directory, and type "cd >> <tab><tab>", the shell offers 178 possibilities. If I restrict it to an
initial letter and hit <tab> once, I think the spurious offerings are from >> $HOME. How can I make it not do that and only offer me things I ask for?
Do you perhaps have the CDPATH variable set? That might affect tab completion for the cd command.
On 9/7/24 09:26, Greg Wooledge wrote:
On Sat, Sep 07, 2024 at 08:56:08 -0400, Eben King wrote:
Hi. I have bash 5.2.15(1). When I cd into an empty directory, and
type "cd <tab><tab>", the shell offers 178 possibilities. If I
restrict it to an initial letter and hit <tab> once, I think the
spurious offerings are from $HOME. How can I make it not do that and
only offer me things I ask for?
Do you perhaps have the CDPATH variable set? That might affect tab
completion for the cd command.
eben@cerberus:~$ echo "$CDPATH" :~:/
0
eben@cerberus:~$ grep CDPATH /etc/profile /etc/profile.d/* ~/.profile ~/.bash_profile > 1
eben@cerberus:~$
In fact I do. Good catch. Any idea where it could be set, other than
the places I looked?
Got it. It was in ~/.bash-vars which was sourced from ~/.bash_profile . Is that a standard thing, or just some "brilliant" idea I had once upon a time?
By the way, there's a trick you can use to find out where shell variables
are being defined:
PS4='+ $BASH_SOURCE:$FUNCNAME:$LINENO:' bash -ilxc : 2>&1 | grep CDPATH
The -il options run an interactive login shell. If you need to check an interactive non-login shell instead, just change the options to -ixc.
This won't work as root, because PS4 from the environment is suppressed
for security reasons when running bash as root.
By the way, there's a trick you can use to find out where shell variables
are being defined:
PS4='+ $BASH_SOURCE:$FUNCNAME:$LINENO:' bash -ilxc : 2>&1 | grep CDPATH
Got it. It was in ~/.bash-vars which was sourced from ~/.bash_profile . Is that a standard thing, or just some "brilliant" idea I had once upon a time?
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 148:50:41 |
| Calls: | 12,091 |
| Calls today: | 4 |
| Files: | 15,000 |
| Messages: | 6,517,560 |