1
0
mirror of https://github.com/wting/autojump synced 2026-03-02 03:49:26 +00:00

initial windows support

This commit is contained in:
Michael Lawson
2014-01-12 19:34:28 +00:00
parent 09d8992289
commit 53eeed8a99
9 changed files with 128 additions and 41 deletions

View File

@@ -50,6 +50,7 @@ from autojump_utils import get_tab_entry_info
from autojump_utils import get_pwd
from autojump_utils import has_uppercase
from autojump_utils import is_osx
from autojump_utils import is_windows
from autojump_utils import last
from autojump_utils import print_entry
from autojump_utils import print_local
@@ -72,6 +73,10 @@ def set_defaults():
os.path.expanduser('~'),
'Library',
'autojump')
elif is_windows():
data_home = os.path.join(
os.getenv('LOCALAPPDATA'),
'autojump')
else:
data_home = os.getenv(
'XDG_DATA_HOME',
@@ -258,13 +263,13 @@ def match_consecutive(needles, haystack, ignore_case=False):
(path="/moo/foo/baz", weight=10),
(path="/foo/baz", weight=10)]
"""
regex_no_sep = '[^' + os.sep + ']*'
regex_one_sep = regex_no_sep + os.sep + regex_no_sep
sep = os.sep.encode('string-escape')
regex_no_sep = '[^' + sep + ']*'
regex_one_sep = regex_no_sep + sep + regex_no_sep
regex_no_sep_end = regex_no_sep + '$'
# can't use compiled regex because of flags
regex_needle = regex_one_sep.join(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,
@@ -336,7 +341,6 @@ def print_stats(data, data_path):
def main(args): # noqa
config = set_defaults()
# all arguments are mutually exclusive
if args.add:
save(config, first(add_path(load(config), args.add)))

2
bin/autojump.bat Normal file
View File

@@ -0,0 +1,2 @@
@echo off
python %~dp0\autojump %*

8
bin/autojump.lua Normal file
View File

@@ -0,0 +1,8 @@
local HOME = clink.get_env("USERPROFILE") .."\\"
local AUTOJUMP_BIN = HOME .. ".autojump\\bin\\autojump"
function autojump_add_to_database()
os.execute("python " .. AUTOJUMP_BIN .. " --add " .. clink.get_cwd())
end
clink.prompt.register_filter(autojump_add_to_database, 99)

15
bin/j.bat Normal file
View File

@@ -0,0 +1,15 @@
@echo off
echo %*|>nul findstr /rx \-.*
if ERRORLEVEL 1 (
for /f %%G in ('python %~dp0\autojump %*') do set new_path=%%G
if exist %new_path%/nul (
cd %new_path%
) else (
echo autojump: directory %* not found
echo try `autojump --help` for more information
)
echo %new_path%
) else (
python %~dp0\autojump %*
)

8
bin/jc.bat Normal file
View File

@@ -0,0 +1,8 @@
@echo off
echo %*|>nul findstr /rx \-.*
if ERRORLEVEL 1 (
%~dp0\j.bat %cd% %*
) else (
python %~dp0\autojump %*
)

8
bin/jco.bat Normal file
View File

@@ -0,0 +1,8 @@
@echo off
echo %*|>nul findstr /rx \-.*
if ERRORLEVEL 1 (
%~dp0\jc.bat %cd% %*
) else (
python %~dp0\autojump %*
)

15
bin/jo.bat Normal file
View File

@@ -0,0 +1,15 @@
@echo off
echo %*|>nul findstr /rx \-.*
if ERRORLEVEL 1 (
for /f %%G in ('python %~dp0\autojump %*') do set new_path=%%G
if exist %new_path%/nul (
start %new_path%
) else (
echo autojump: directory %* not found
echo try `autojump --help` for more information
)
echo %new_path%
) else (
python %~dp0\autojump %*
)