scop / bash-completion

Programmable completion functions for bash
GNU General Public License v2.0
2.92k stars 380 forks source link

Append '/' while tab completing variables that contains path to directories #171

Open siteshwar opened 7 years ago

siteshwar commented 7 years ago

With bash-completion scripts, '/' is not appended while tab completing directory names.

With bash-completion scripts :

# echo $HOME<tab>

will expand to:

# echo $HOME<space>

Without bash-completion scripts :

# echo $HOME<tab>

will expand to:

# echo $HOME/
scop commented 7 years ago

Not quite sure how to do that. Appending the / (plus setting nospace mode) is not enough IMO, we want to set to filename completion mode (compopt -o filenames) when that occurs so one can sanely complete filenames following the variable and the slash. But when doing that, the $ gets backslash escaped :(

pbnj commented 6 years ago

But when doing that, the $ gets backslash escaped

Interestingly, I seem to be running exactly into what you've described (compopt causing $ in environment variables to get escaped with backslashes \)

screen shot 2018-06-14 at 4 21 06 pm

If I brew uninstall bash-completion@2 and restart my shell, environment variables do not get escaped.

pbnj commented 6 years ago

I came across the same question on this thread which recommended:

shopt -s direxpand (for bash >= 4.2.29)

That resolved the issue of escaping $ when hitting TAB for me.

pbnj commented 6 years ago

With regards to the original question of appending a / while tab completing variables that contain path to directories, adding the following to my ~/.inputrc resolves the issue:

$include /etc/inputrc
set completion-ignore-case On
+ set mark-symlinked-directories on
set show-all-if-ambiguous on
set visible-stats on
set page-completions off