Allow completions to work for files, directories, and aliases.

main
Steven Silvester 11 years ago
parent f8629ab8ff
commit 5a3d3b795c

@ -77,19 +77,23 @@ class BashKernel(Kernel):
def do_complete(self, code, cursor_pos):
code = code[:cursor_pos]
default = {'matches': [], 'cursor_start': 0,
'cursor_end': cursor_pos, 'metadata': dict(),
'status': 'ok'}
if code[-1] == ' ':
return
return default
tokens = code.replace(';', ' ').split()
if not tokens:
return
return default
token = tokens[-1]
# check for valid function name
if not re.match('\A[a-zA-Z_]', token):
return
start = cursor_pos - len(token)
cmd = 'compgen -c %s' % token
cmd = 'compgen -cdfa %s' % token
output = self.bashwrapper.run_command(cmd).rstrip()
return {'matches': output.split(), 'cursor_start': start,
matches = output.split()
if not matches:
return default
matches = [m for m in matches if m.startswith(token)]
return {'matches': matches, 'cursor_start': start,
'cursor_end': cursor_pos, 'metadata': dict(),
'status': 'ok'}

Loading…
Cancel
Save