mirror of
https://github.com/xonsh/xonsh.git
synced 2025-03-05 17:00:58 +01:00
add space escaping to bash completion function
On Linux, if there's a foldername with a space in it, like "bad folder" then tab-completion using `cd` will wrap single quotes around the name, e.g. ``` cd bad(TAB) ``` completes to ``` cd 'bad folder/' ``` This behavior is encoded in `path_complete` in `completer.py`. But if you want to remove that poorly named folder, the argument to `rm` is completed by `bash_complete` which didn't have this tweak and so the result is ``` rm -r bad(TAB) ``` leads to ``` rm -r bad folder /usr/bin/rm: cannot remove 'bad': No such file or directory /usr/bin/rm: cannot remove 'folder/': No such file or directory ``` This tweaks the `bash_complete` function so that ``` rm -r bad(TAB) ``` returns ``` rm -r 'bad folder/' ```
This commit is contained in:
parent
d3447bef08
commit
4651e66154
1 changed files with 6 additions and 1 deletions
|
@ -316,7 +316,12 @@ class Completer(object):
|
|||
out = ''
|
||||
|
||||
space = ' '
|
||||
rtn = {s + space if s[-1:].isalnum() else s for s in out.splitlines()}
|
||||
slash = '/'
|
||||
rtn = {_normpath(repr(s + (slash if os.path.isdir(s) else '')))
|
||||
if space in s else
|
||||
s + space
|
||||
if s[-1:].isalnum() else
|
||||
s for s in out.splitlines()}
|
||||
return rtn
|
||||
|
||||
def _source_completions(self):
|
||||
|
|
Loading…
Add table
Reference in a new issue