mirror of
https://github.com/wting/autojump
synced 2025-06-13 12:54:07 +00:00
add quotes for bash output
This commit is contained in:
parent
3125c65378
commit
1e4ca4d67e
@ -321,7 +321,7 @@ def main():
|
|||||||
result = first(find_matches(entriefy(load(config)), args.directory))
|
result = first(find_matches(entriefy(load(config)), args.directory))
|
||||||
|
|
||||||
if result:
|
if result:
|
||||||
print(encode_local(result.path))
|
print(encode_local(surround_quotes(result.path)))
|
||||||
else:
|
else:
|
||||||
# always return something so the calling shell function has an
|
# always return something so the calling shell function has an
|
||||||
# argument to `cd` to
|
# argument to `cd` to
|
||||||
|
10
bin/utils.py
10
bin/utils.py
@ -63,6 +63,10 @@ def has_uppercase(string):
|
|||||||
return any(unicodedata.category(c) == 'Lu' for c in unicode(string))
|
return any(unicodedata.category(c) == 'Lu' for c in unicode(string))
|
||||||
|
|
||||||
|
|
||||||
|
def in_bash():
|
||||||
|
return 'bash' in os.getenv('SHELL')
|
||||||
|
|
||||||
|
|
||||||
def is_python2():
|
def is_python2():
|
||||||
return sys.version_info[0] == 2
|
return sys.version_info[0] == 2
|
||||||
|
|
||||||
@ -115,6 +119,12 @@ def second(xs):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def surround_quotes(string):
|
||||||
|
if in_bash():
|
||||||
|
return '"{}"'.format(string)
|
||||||
|
return string
|
||||||
|
|
||||||
|
|
||||||
def take(n, iterable):
|
def take(n, iterable):
|
||||||
"""Return first n items of an iterable."""
|
"""Return first n items of an iterable."""
|
||||||
return islice(iterable, n)
|
return islice(iterable, n)
|
||||||
|
Loading…
Reference in New Issue
Block a user