autojump
autojump copied to clipboard
Problem with running autojump on Windows 10 and python 3.9
Traceback (most recent call last):
File "C:\Users\yixiu\AppData\Local\autojump\bin\autojump", line 342, in
re.escape(os.sep) because on windows os.sep is \ and need escape #618
CMD works, but PowerShell can't find the path properly.
I followed this guide https://leetschau.github.io/autojump-in-windows-console.html and added these lines to bin/autojump_math.py:78-88:
sep = '\\\\' if os.sep == '\\' else os.sep
regex_no_sep = '[^' + sep + ']*'
regex_no_sep_end = regex_no_sep + '$'
regex_one_sep = regex_no_sep + sep + regex_no_sep
And I also had to add the /bin folder of the repo to the Environmental variables of windows. The install script didn't cut it (maybe because I was using it in PowerShell?)
I still however can't get it to work with PowerShell, but it works on command prompt 🤷
Using python version 3.9.2.
I can confirm the same traceback issue on Python 3.7.9 and the fix @JoiGud mentions works. In my case, I did
def match_consecutive(needles, haystack, ignore_case=False):
"""
Matches consecutive needles at the end of a path.
For example:
needles = ['foo', 'baz']
haystack = [
(path='/foo/bar/baz', weight=10),
(path='/foo/baz/moo', weight=10),
(path='/moo/foo/baz', weight=10),
(path='/foo/baz', weight=10),
]
# We can't actually use re.compile because of re.UNICODE
regex_needle = re.compile(r'''
foo # needle #1
[^/]* # all characters except os.sep zero or more times
/ # os.sep
[^/]* # all characters except os.sep zero or more times
baz # needle #2
[^/]* # all characters except os.sep zero or more times
$ # end of string
''')
result = [
(path='/moo/foo/baz', weight=10),
(path='/foo/baz', weight=10),
]
"""
sep = '\\\\' if os.sep == '\\' else os.sep
regex_no_sep = '[^' + sep + ']*'
regex_no_sep_end = regex_no_sep + '$'
regex_one_sep = regex_no_sep + sep + regex_no_sep
regex_needle = regex_one_sep.join(imap(re.escape, needles)) + regex_no_sep_end
regex_flags = re.IGNORECASE | re.UNICODE if ignore_case else re.UNICODE
found = lambda entry: re.search(
regex_needle,
entry.path,
flags=regex_flags,
)
return ifilter(found, haystack)
could anyone tell me how to run autojump in powershell ? I can jump in cmd but nothing happend in powershell