summaryrefslogtreecommitdiff
path: root/cmd2.py
diff options
context:
space:
mode:
authorTodd Leonhardt <todd.leonhardt@gmail.com>2017-06-25 15:18:50 -0400
committerTodd Leonhardt <todd.leonhardt@gmail.com>2017-06-25 15:18:50 -0400
commit9f85d0a989039b23b831d18694183ba73ca83266 (patch)
treea0554a86ca8b255c027cd21ce4d9ed200a44d153 /cmd2.py
parentcc118281df23738dbfc41045ca05179255574afb (diff)
downloadcmd2-git-9f85d0a989039b23b831d18694183ba73ca83266.tar.gz
Ensure path completion results are sorted alphabetically on all OSes
Diffstat (limited to 'cmd2.py')
-rwxr-xr-xcmd2.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/cmd2.py b/cmd2.py
index 65b7eeee..3ae1c599 100755
--- a/cmd2.py
+++ b/cmd2.py
@@ -432,7 +432,7 @@ else:
else:
xclipproc.stdin.write(txt)
xclipproc.stdin.close()
-
+
# but we want it in both the "primary" and "mouse" clipboards
xclipproc = subprocess.Popen('xclip', shell=True, stdout=subprocess.PIPE, stdin=subprocess.PIPE)
if six.PY3:
@@ -1412,7 +1412,8 @@ class Cmd(cmd.Cmd):
elif os.path.isdir(path_completions[0]) and add_sep_after_tilde:
completions[0] = os.path.sep + completions[0]
- return completions
+ # If there are multiple completions, then sort them alphabetically
+ return sorted(completions)
# Enable tab completion of paths for relevant commands
complete_edit = path_complete
@@ -1453,7 +1454,8 @@ class Cmd(cmd.Cmd):
if len(exes) == 1 and endidx == len(line):
exes[0] += ' '
- return exes
+ # If there are multiple completions, then sort them alphabetically
+ return sorted(exes)
# noinspection PyUnusedLocal
def complete_shell(self, text, line, begidx, endidx):