Skip to content

Commit da4ad38

Browse files
committed
Fix expansion of usernames in file completion.
1 parent bd9d9b1 commit da4ad38

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

bpython/cli.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -638,12 +638,13 @@ def _complete(self, tab=False):
638638
if cs and tab:
639639
# Filename completion
640640
self.matches = list()
641-
user_dir = os.path.expanduser('~')
641+
username = cs.split(os.path.sep, 1)[0]
642+
user_dir = os.path.expanduser(username)
642643
for filename in glob(os.path.expanduser(cs + '*')):
643644
if os.path.isdir(filename):
644645
filename += os.path.sep
645646
if cs.startswith('~'):
646-
filename = '~' + filename[len(user_dir):]
647+
filename = username + filename[len(user_dir):]
647648
self.matches.append(filename)
648649
self.matches_iter.update(cs, self.matches)
649650
return bool(self.matches)

0 commit comments

Comments
 (0)