1
0
mirror of https://github.com/wting/autojump synced 2024-10-27 20:34:07 +00:00

Compare commits

..

No commits in common. "master" and "release-v22.5.0" have entirely different histories.

24 changed files with 379 additions and 609 deletions

2
.gitattributes vendored
View File

@ -1,2 +1,2 @@
# Ensure batch files are crlf
*.bat text eol=crlf
*.bat text eol=crlf

1
.gitignore vendored
View File

@ -5,6 +5,5 @@ __pycache__
*~
*.tar.gz
*.patch
.pytest_cache
.tox
tags

View File

@ -1,51 +1,30 @@
repos:
- repo: git@github.com:pre-commit/pre-commit-hooks.git
rev: v1.4.0
hooks:
- id: autopep8-wrapper
language_version: python2
args:
- --in-place
- --aggressive
- --aggressive
- --ignore=E731
- --max-line-length=131
- id: check-added-large-files
language_version: python2
- id: check-ast
language_version: python2
- id: check-case-conflict
language_version: python2
- id: check-docstring-first
language_version: python2
- id: debug-statements
language_version: python2
- id: double-quote-string-fixer
language_version: python2
- id: end-of-file-fixer
language_version: python2
exclude_types: [batch, lua]
- id: fix-encoding-pragma
language_version: python2
- id: flake8
language_version: python2
args:
- --max-complexity=10
- --max-line-length=131
- --ignore=E402,E731
- --exclude=bin/autojump_argparse.py
- id: name-tests-test
language_version: python2
- id: requirements-txt-fixer
language_version: python2
- id: trailing-whitespace
language_version: python2
- repo: git@github.com:asottile/reorder_python_imports.git
rev: v1.1.1
hooks:
- id: reorder-python-imports
language_version: python2
- repo: git@github.com:asottile/add-trailing-comma
rev: v0.7.0
hooks:
- id: add-trailing-comma
- repo: git@github.com:pre-commit/pre-commit-hooks.git
sha: 35548254adb636ce52b5574eb1904b8c795b673e
hooks:
- id: autopep8-wrapper
args:
- --in-place
- --aggressive
- --aggressive
- --max-line-length=131
- id: check-added-large-files
- id: check-ast
- id: check-case-conflict
- id: check-docstring-first
- id: debug-statements
- id: double-quote-string-fixer
- id: end-of-file-fixer
- id: fix-encoding-pragma
- id: flake8
args:
- --max-complexity=10
- --max-line-length=131
- --ignore=E126,E128,E731
- --exclude=bin/autojump_argparse.py
- id: requirements-txt-fixer
- id: trailing-whitespace
- repo: git@github.com:asottile/reorder_python_imports.git
sha: 017e2f64306853ec7f000db52b8280da27eb3b96
hooks:
- id: reorder-python-imports
language_version: python2.7

View File

@ -1,5 +1,5 @@
## Summary of release changes, see commit history for more details:
## https://github.com/wting/autojump/commits/master/
## https://github.com/joelthelion/autojump/commits/master/
### Release v22.4.0:
- minor zsh performance improvement

View File

@ -1,31 +1,21 @@
VERSION = $(shell grep -oE "[0-9]+\.[0-9]+\.[0-9]+" bin/autojump)
TAGNAME = release-v$(VERSION)
.PHONY: install
.PHONY: clean docs install uninstall pre-commit lint tar test
install:
./install.py
.PHONY: uninstall
uninstall:
./uninstall.py
.PHONY: docs
docs:
@echo "% autojump(1) ${TAGNAME}" >docs/manpage_header.md
@echo "%" >>docs/manpage_header.md
@echo "% $(shell \date +%Y-%m-%d)" >>docs/manpage_header.md
pandoc -s -w man docs/manpage_header.md docs/header.md docs/body.md -o docs/autojump.1
pandoc -s -w markdown docs/header.md docs/install.md docs/body.md -o README.md
.PHONY: lint
lint: pre-commit
@tox -e pre-commit -- run --all-files
.PHONY: pre-commit
pre-commit:
@tox -e pre-commit -- install -f --install-hooks
.PHONY: release
release: docs
# Check for tag existence
# git describe release-$(VERSION) 2>&1 >/dev/null || exit 1
@ -43,25 +33,20 @@ release: docs
git archive --format=tar --prefix autojump_v$(VERSION)/ $(TAGNAME) | gzip > autojump_v$(VERSION).tar.gz
sha1sum autojump_v$(VERSION).tar.gz
.PHONY: tar
tar:
# Create tagged archive
git archive --format=tar --prefix autojump_v$(VERSION)/ $(TAGNAME) | gzip > autojump_v$(VERSION).tar.gz
sha1sum autojump_v$(VERSION).tar.gz
.PHONY: test
test: pre-commit
@tox
.PHONY: test-xfail
test-xfail: pre-commit
@tox -- --runxfail
.PHONY: test-fast
test-fast: pre-commit
@tox -e py27
.PHONY: clean
clean:
@find . -type f -iname '*.py[co]' -delete
@find . -type d -iname '__pycache__' -delete

View File

@ -63,61 +63,29 @@ INSTALLATION
### REQUIREMENTS
- Python v2.6+ or Python v3.3+
- Supported shells
- bash - first class support
- zsh - first class support
- fish - community supported
- tcsh - community supported
- clink - community supported
- Supported platforms
- Linux - first class support
- OS X - first class support
- Windows - community supported
- BSD - community supported
- Supported installation methods
- source code - first class support
- Debian and derivatives - first class support
- ArchLinux / Gentoo / openSUSE / RedHat and derivatives -
community supported
- Homebrew / MacPorts - community supported
Due to limited time and resources, only "first class support" items will
be maintained by the primary committers. All "community supported" items
will be updated based on pull requests submitted by the general public.
Please continue opening issues and providing feedback for community
supported items since consolidating information helps other users
troubleshoot and submit enhancements and fixes.
### MANUAL
Grab a copy of autojump:
git clone git://github.com/wting/autojump.git
Run the installation script and follow on screen instructions.
cd autojump
./install.py or ./uninstall.py
- Python v2.6+ except v3.2
- Supported shells:
- bash v4.0+
- zsh
- fish
- tcsh (experimental)
- clink (Windows, experimental)
### AUTOMATIC
#### Linux
autojump is included in the following distro repositories, please use
relevant package management utilities to install (e.g. apt-get, yum,
pacman, etc):
relevant package management utilities to install (e.g. yum, apt-get,
etc):
- Debian, Ubuntu, Linux Mint
- Debian testing/unstable, Ubuntu, Linux Mint
All Debian-derived distros require manual activation for policy
reasons, please see `/usr/share/doc/autojump/README.Debian`.
- RedHat, Fedora, CentOS
Install `autojump-zsh` for zsh, `autojump-fish` for fish, etc.
- RedHat, Fedora, CentOS (install `autojump-zsh` for zsh,
`autojump-fish` for fish, etc.)
- ArchLinux
- Gentoo
- Frugalware
@ -129,7 +97,7 @@ Homebrew is the recommended installation method for Mac OS X:
brew install autojump
MacPorts is also available:
MacPorts also available:
port install autojump
@ -139,6 +107,17 @@ Windows
Windows support is enabled by [clink](https://mridgers.github.io/clink/)
which should be installed prior to installing autojump.
### MANUAL
Grab a copy of autojump:
git clone git://github.com/joelthelion/autojump.git
Run the installation script and follow on screen instructions.
cd autojump
./install.py or ./uninstall.py
KNOWN ISSUES
------------
@ -158,7 +137,7 @@ REPORTING BUGS
For any questions or issues please visit:
https://github.com/wting/autojump/issues
https://github.com/joelthelion/autojump/issues
AUTHORS
-------

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Copyright © 2008-2012 Joel Schaerer
@ -20,12 +20,12 @@
"""
from __future__ import print_function
import os
import sys
from itertools import chain
from math import sqrt
from operator import attrgetter
from operator import itemgetter
import os
import sys
if sys.version_info[0] == 3:
ifilter = filter
@ -65,7 +65,7 @@ from autojump_utils import sanitize
from autojump_utils import take
from autojump_utils import unico
VERSION = '22.5.3'
VERSION = '22.5.0'
FUZZY_MATCH_THRESHOLD = 0.6
TAB_ENTRIES_COUNT = 9
TAB_SEPARATOR = '__'
@ -75,9 +75,14 @@ def set_defaults():
config = {}
if is_osx():
data_home = os.path.join(os.path.expanduser('~'), 'Library')
data_home = os.path.join(
os.path.expanduser('~'),
'Library',
'autojump')
elif is_windows():
data_home = os.getenv('APPDATA')
data_home = os.path.join(
os.getenv('APPDATA'),
'autojump')
else:
data_home = os.getenv(
'XDG_DATA_HOME',
@ -85,10 +90,10 @@ def set_defaults():
os.path.expanduser('~'),
'.local',
'share',
),
)
config['data_path'] = os.path.join(data_home, 'autojump', 'autojump.txt')
config['backup_path'] = os.path.join(data_home, 'autojump', 'autojump.txt.bak')
'autojump'))
config['data_path'] = os.path.join(data_home, 'autojump.txt')
config['backup_path'] = os.path.join(data_home, 'autojump.txt.bak')
return config
@ -96,42 +101,33 @@ def set_defaults():
def parse_arguments():
parser = ArgumentParser(
description='Automatically jump to directory passed as an argument.',
epilog='Please see autojump(1) man pages for full documentation.',
)
epilog="Please see autojump(1) man pages for full documentation.")
parser.add_argument(
'directory', metavar='DIRECTORY', nargs='*', default='',
help='directory to jump to',
)
help='directory to jump to')
parser.add_argument(
'-a', '--add', metavar='DIRECTORY',
help='add path',
)
help='add path')
parser.add_argument(
'-i', '--increase', metavar='WEIGHT', nargs='?', type=int,
const=10, default=False,
help='increase current directory weight',
)
help='increase current directory weight')
parser.add_argument(
'-d', '--decrease', metavar='WEIGHT', nargs='?', type=int,
const=15, default=False,
help='decrease current directory weight',
)
help='decrease current directory weight')
parser.add_argument(
'--complete', action='store_true', default=False,
help='used for tab completion',
)
'--complete', action="store_true", default=False,
help='used for tab completion')
parser.add_argument(
'--purge', action='store_true', default=False,
help='remove non-existent paths from database',
)
'--purge', action="store_true", default=False,
help='remove non-existent paths from database')
parser.add_argument(
'-s', '--stat', action='store_true', default=False,
help='show database entries and their key weights',
)
'-s', '--stat', action="store_true", default=False,
help='show database entries and their key weights')
parser.add_argument(
'-v', '--version', action='version', version='%(prog)s v' +
VERSION, help='show version information',
)
'-v', '--version', action="version", version="%(prog)s v" +
VERSION, help='show version information')
return parser.parse_args()
@ -171,7 +167,7 @@ def detect_smartcase(needles):
def find_matches(entries, needles, check_entries=True):
"""Return an iterator to matching entries."""
# TODO(wting|2014-02-24): replace assertion with unit test
assert isinstance(needles, list), 'Needles must be a list.'
assert isinstance(needles, list), "Needles must be a list."
ignore_case = detect_smartcase(needles)
try:
@ -191,17 +187,14 @@ def find_matches(entries, needles, check_entries=True):
data = sorted(
entries,
key=attrgetter('weight', 'path'),
reverse=True,
)
reverse=True)
return ifilter(
lambda entry: not is_cwd(entry) and path_exists(entry),
chain(
match_consecutive(needles, data, ignore_case),
match_fuzzy(needles, data, ignore_case),
match_anywhere(needles, data, ignore_case),
),
)
match_anywhere(needles, data, ignore_case)))
def handle_tab_completion(needle, entries):
@ -213,33 +206,24 @@ def handle_tab_completion(needle, entries):
get_ith_path = lambda i, iterable: last(take(i, iterable)).path
print_local(get_ith_path(
tab_index,
find_matches(entries, [tab_needle], check_entries=False),
))
find_matches(entries, [tab_needle], check_entries=False)))
elif tab_needle:
# found partial tab completion entry
print_tab_menu(
tab_needle,
take(
TAB_ENTRIES_COUNT, find_matches(
entries,
[tab_needle],
check_entries=False,
),
),
TAB_SEPARATOR,
)
take(TAB_ENTRIES_COUNT, find_matches(
entries,
[tab_needle],
check_entries=False)),
TAB_SEPARATOR)
else:
print_tab_menu(
needle,
take(
TAB_ENTRIES_COUNT, find_matches(
entries,
[needle],
check_entries=False,
),
),
TAB_SEPARATOR,
)
take(TAB_ENTRIES_COUNT, find_matches(
entries,
[needle],
check_entries=False)),
TAB_SEPARATOR)
def purge_missing_paths(entries):
@ -252,26 +236,25 @@ def print_stats(data, data_path):
for path, weight in sorted(data.items(), key=itemgetter(1)):
print_entry(Entry(path, weight))
print('________________________________________\n')
print('%d:\t total weight' % sum(data.values()))
print('%d:\t number of entries' % len(data))
print("________________________________________\n")
print("%d:\t total weight" % sum(data.values()))
print("%d:\t number of entries" % len(data))
try:
print_local(
'%.2f:\t current directory weight' % data.get(os.getcwdu(), 0),
)
"%.2f:\t current directory weight" % data.get(os.getcwdu(), 0))
except OSError:
# current directory no longer exists
pass
print('\ndata:\t %s' % data_path)
print("\ndata:\t %s" % data_path)
def main(args): # noqa
if not is_autojump_sourced() and not is_windows():
print("Please source the correct autojump file in your shell's")
print('startup file. For more information, please reinstall autojump')
print('and read the post installation instructions.')
print("startup file. For more information, please reinstall autojump")
print("and read the post installation instructions.")
return 1
config = set_defaults()
@ -282,8 +265,7 @@ def main(args): # noqa
elif args.complete:
handle_tab_completion(
needle=first(chain(sanitize(args.directory), [''])),
entries=entriefy(load(config)),
)
entries=entriefy(load(config)))
elif args.decrease:
data, entry = decrease_path(load(config), get_pwd(), args.decrease)
save(config, data)
@ -296,7 +278,7 @@ def main(args): # noqa
old_data = load(config)
new_data = dictify(purge_missing_paths(entriefy(old_data)))
save(config, new_data)
print('Purged %d entries.' % (len(old_data) - len(new_data)))
print("Purged %d entries." % (len(old_data) - len(new_data)))
elif args.stat:
print_stats(load(config), config['data_path'])
elif not args.directory:
@ -305,8 +287,7 @@ def main(args): # noqa
print_local(first(chain(
imap(attrgetter('path'), find_matches(entries, [''])),
# always return a path to calling shell functions
['.'],
)))
['.'])))
else:
entries = entriefy(load(config))
needles = sanitize(args.directory)
@ -325,18 +306,15 @@ def main(args): # noqa
print_local(
get_ith_path(
tab_index,
find_matches(entries, [tab_needle]),
),
)
find_matches(entries, [tab_needle])))
else:
print_local(first(chain(
imap(attrgetter('path'), find_matches(entries, needles)),
# always return a path to calling shell functions
['.'],
)))
['.'])))
return 0
if __name__ == '__main__':
if __name__ == "__main__":
sys.exit(main(parse_arguments()))

View File

@ -50,7 +50,7 @@ function j
case '*'
set -l output (autojump $argv)
# Check for . and attempt a regular cd
if [ $output = "." ]
if [ $output = "." ]
cd $argv
else
if test -d "$output"

View File

@ -2,7 +2,7 @@ local AUTOJUMP_DIR = debug.getinfo(1, "S").source:match[[^@?(.*[\/])[^\/]-$]] ..
local AUTOJUMP_BIN_DIR = AUTOJUMP_DIR .. "\\bin"
local AUTOJUMP_BIN = (AUTOJUMP_BIN_DIR or clink.get_env("LOCALAPPDATA") .. "\\autojump\\bin") .. "\\autojump"
function autojump_add_to_database()
function autojump_add_to_database()
os.execute("python " .. "\"" .. AUTOJUMP_BIN .. "\"" .. " --add " .. "\"" .. clink.get_cwd() .. "\"" .. " 2> " .. clink.get_env("TEMP") .. "\\autojump_error.txt")
end
@ -12,10 +12,10 @@ function autojump_completion(word)
for line in io.popen("python " .. "\"" .. AUTOJUMP_BIN .. "\"" .. " --complete " .. word):lines() do
clink.add_match(line)
end
return {}
return {}
end
local autojump_parser = clink.arg.new_parser()
autojump_parser:set_arguments({ autojump_completion })
clink.arg.register_parser("j", autojump_parser)
clink.arg.register_parser("j", autojump_parser)

View File

@ -175,13 +175,11 @@ class HelpFormatter(object):
provided by the class are considered an implementation detail.
"""
def __init__(
self,
prog,
indent_increment=2,
max_help_position=24,
width=None,
):
def __init__(self,
prog,
indent_increment=2,
max_help_position=24,
width=None):
# default setting for width
if width is None:
@ -288,10 +286,8 @@ class HelpFormatter(object):
# update the maximum item length
invocation_length = max([len(s) for s in invocations])
action_length = invocation_length + self._current_indent
self._action_max_length = max(
self._action_max_length,
action_length,
)
self._action_max_length = max(self._action_max_length,
action_length)
# add the item to the list
self._add_item(self._format_action, [action])
@ -311,11 +307,9 @@ class HelpFormatter(object):
return help
def _join_parts(self, part_strings):
return ''.join([
part
for part in part_strings
if part and part is not SUPPRESS
])
return ''.join([part
for part in part_strings
if part and part is not SUPPRESS])
def _format_usage(self, usage, actions, groups, prefix):
if prefix is None:
@ -514,10 +508,8 @@ class HelpFormatter(object):
def _format_action(self, action):
# determine the required width and the entry label
help_position = min(
self._action_max_length + 2,
self._max_help_position,
)
help_position = min(self._action_max_length + 2,
self._max_help_position)
help_width = self._width - help_position
action_width = help_position - self._current_indent - 2
action_header = self._format_action_invocation(action)
@ -649,10 +641,8 @@ class HelpFormatter(object):
def _fill_text(self, text, width, indent):
text = self._whitespace_matcher.sub(' ', text).strip()
return _textwrap.fill(
text, width, initial_indent=indent,
subsequent_indent=indent,
)
return _textwrap.fill(text, width, initial_indent=indent,
subsequent_indent=indent)
def _get_help_string(self, action):
return action.help
@ -734,10 +724,8 @@ class ArgumentError(Exception):
format = '%(message)s'
else:
format = 'argument %(argument_name)s: %(message)s'
return format % dict(
message=self.message,
argument_name=self.argument_name,
)
return format % dict(message=self.message,
argument_name=self.argument_name)
class ArgumentTypeError(Exception):
@ -802,19 +790,17 @@ class Action(_AttributeHolder):
help string. If None, the 'dest' value will be used as the name.
"""
def __init__(
self,
option_strings,
dest,
nargs=None,
const=None,
default=None,
type=None,
choices=None,
required=False,
help=None,
metavar=None,
):
def __init__(self,
option_strings,
dest,
nargs=None,
const=None,
default=None,
type=None,
choices=None,
required=False,
help=None,
metavar=None):
self.option_strings = option_strings
self.dest = dest
self.nargs = nargs
@ -846,25 +832,21 @@ class Action(_AttributeHolder):
class _StoreAction(Action):
def __init__(
self,
option_strings,
dest,
nargs=None,
const=None,
default=None,
type=None,
choices=None,
required=False,
help=None,
metavar=None,
):
def __init__(self,
option_strings,
dest,
nargs=None,
const=None,
default=None,
type=None,
choices=None,
required=False,
help=None,
metavar=None):
if nargs == 0:
raise ValueError(
'nargs for store actions must be > 0; if you '
'have nothing to store, actions such as store '
'true or store const may be more appropriate',
)
raise ValueError('nargs for store actions must be > 0; if you '
'have nothing to store, actions such as store '
'true or store const may be more appropriate')
if const is not None and nargs != OPTIONAL:
raise ValueError('nargs must be %r to supply const' % OPTIONAL)
super(_StoreAction, self).__init__(
@ -877,8 +859,7 @@ class _StoreAction(Action):
choices=choices,
required=required,
help=help,
metavar=metavar,
)
metavar=metavar)
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, values)
@ -886,16 +867,14 @@ class _StoreAction(Action):
class _StoreConstAction(Action):
def __init__(
self,
option_strings,
dest,
const,
default=None,
required=False,
help=None,
metavar=None,
):
def __init__(self,
option_strings,
dest,
const,
default=None,
required=False,
help=None,
metavar=None):
super(_StoreConstAction, self).__init__(
option_strings=option_strings,
dest=dest,
@ -903,8 +882,7 @@ class _StoreConstAction(Action):
const=const,
default=default,
required=required,
help=help,
)
help=help)
def __call__(self, parser, namespace, values, option_string=None):
setattr(namespace, self.dest, self.const)
@ -912,65 +890,55 @@ class _StoreConstAction(Action):
class _StoreTrueAction(_StoreConstAction):
def __init__(
self,
option_strings,
dest,
default=False,
required=False,
help=None,
):
def __init__(self,
option_strings,
dest,
default=False,
required=False,
help=None):
super(_StoreTrueAction, self).__init__(
option_strings=option_strings,
dest=dest,
const=True,
default=default,
required=required,
help=help,
)
help=help)
class _StoreFalseAction(_StoreConstAction):
def __init__(
self,
option_strings,
dest,
default=True,
required=False,
help=None,
):
def __init__(self,
option_strings,
dest,
default=True,
required=False,
help=None):
super(_StoreFalseAction, self).__init__(
option_strings=option_strings,
dest=dest,
const=False,
default=default,
required=required,
help=help,
)
help=help)
class _AppendAction(Action):
def __init__(
self,
option_strings,
dest,
nargs=None,
const=None,
default=None,
type=None,
choices=None,
required=False,
help=None,
metavar=None,
):
def __init__(self,
option_strings,
dest,
nargs=None,
const=None,
default=None,
type=None,
choices=None,
required=False,
help=None,
metavar=None):
if nargs == 0:
raise ValueError(
'nargs for append actions must be > 0; if arg '
'strings are not supplying the value to append, '
'the append const action may be more appropriate',
)
raise ValueError('nargs for append actions must be > 0; if arg '
'strings are not supplying the value to append, '
'the append const action may be more appropriate')
if const is not None and nargs != OPTIONAL:
raise ValueError('nargs must be %r to supply const' % OPTIONAL)
super(_AppendAction, self).__init__(
@ -983,8 +951,7 @@ class _AppendAction(Action):
choices=choices,
required=required,
help=help,
metavar=metavar,
)
metavar=metavar)
def __call__(self, parser, namespace, values, option_string=None):
items = _copy.copy(_ensure_value(namespace, self.dest, []))
@ -994,16 +961,14 @@ class _AppendAction(Action):
class _AppendConstAction(Action):
def __init__(
self,
option_strings,
dest,
const,
default=None,
required=False,
help=None,
metavar=None,
):
def __init__(self,
option_strings,
dest,
const,
default=None,
required=False,
help=None,
metavar=None):
super(_AppendConstAction, self).__init__(
option_strings=option_strings,
dest=dest,
@ -1012,8 +977,7 @@ class _AppendConstAction(Action):
default=default,
required=required,
help=help,
metavar=metavar,
)
metavar=metavar)
def __call__(self, parser, namespace, values, option_string=None):
items = _copy.copy(_ensure_value(namespace, self.dest, []))
@ -1023,22 +987,19 @@ class _AppendConstAction(Action):
class _CountAction(Action):
def __init__(
self,
option_strings,
dest,
default=None,
required=False,
help=None,
):
def __init__(self,
option_strings,
dest,
default=None,
required=False,
help=None):
super(_CountAction, self).__init__(
option_strings=option_strings,
dest=dest,
nargs=0,
default=default,
required=required,
help=help,
)
help=help)
def __call__(self, parser, namespace, values, option_string=None):
new_count = _ensure_value(namespace, self.dest, 0) + 1
@ -1047,20 +1008,17 @@ class _CountAction(Action):
class _HelpAction(Action):
def __init__(
self,
option_strings,
dest=SUPPRESS,
default=SUPPRESS,
help=None,
):
def __init__(self,
option_strings,
dest=SUPPRESS,
default=SUPPRESS,
help=None):
super(_HelpAction, self).__init__(
option_strings=option_strings,
dest=dest,
default=default,
nargs=0,
help=help,
)
help=help)
def __call__(self, parser, namespace, values, option_string=None):
parser.print_help()
@ -1069,21 +1027,18 @@ class _HelpAction(Action):
class _VersionAction(Action):
def __init__(
self,
option_strings,
version=None,
dest=SUPPRESS,
default=SUPPRESS,
help="show program's version number and exit",
):
def __init__(self,
option_strings,
version=None,
dest=SUPPRESS,
default=SUPPRESS,
help="show program's version number and exit"):
super(_VersionAction, self).__init__(
option_strings=option_strings,
dest=dest,
default=default,
nargs=0,
help=help,
)
help=help)
self.version = version
def __call__(self, parser, namespace, values, option_string=None):
@ -1103,15 +1058,13 @@ class _SubParsersAction(Action):
sup = super(_SubParsersAction._ChoicesPseudoAction, self)
sup.__init__(option_strings=[], dest=name, help=help)
def __init__(
self,
option_strings,
prog,
parser_class,
dest=SUPPRESS,
help=None,
metavar=None,
):
def __init__(self,
option_strings,
prog,
parser_class,
dest=SUPPRESS,
help=None,
metavar=None):
self._prog_prefix = prog
self._parser_class = parser_class
@ -1124,8 +1077,7 @@ class _SubParsersAction(Action):
nargs=PARSER,
choices=self._name_parser_map,
help=help,
metavar=metavar,
)
metavar=metavar)
def add_parser(self, name, **kwargs):
# set prog from the existing prefix
@ -1166,8 +1118,7 @@ class _SubParsersAction(Action):
# store any unrecognized options on the object, so that the top
# level parser can decide what to do with them
namespace, arg_strings = parser.parse_known_args(
arg_strings, namespace,
)
arg_strings, namespace)
if arg_strings:
vars(namespace).setdefault(_UNRECOGNIZED_ARGS_ATTR, [])
getattr(namespace, _UNRECOGNIZED_ARGS_ATTR).extend(arg_strings)
@ -1248,13 +1199,11 @@ class Namespace(_AttributeHolder):
class _ActionsContainer(object):
def __init__(
self,
description,
prefix_chars,
argument_default,
conflict_handler,
):
def __init__(self,
description,
prefix_chars,
argument_default,
conflict_handler):
super(_ActionsContainer, self).__init__()
self.description = description
@ -1423,8 +1372,7 @@ class _ActionsContainer(object):
title_group_map[group.title] = self.add_argument_group(
title=group.title,
description=group.description,
conflict_handler=group.conflict_handler,
)
conflict_handler=group.conflict_handler)
# map the actions to their new group
for action in group._group_actions:
@ -1435,8 +1383,7 @@ class _ActionsContainer(object):
# description= then this code will need to be expanded as above
for group in container._mutually_exclusive_groups:
mutex_group = self.add_mutually_exclusive_group(
required=group.required,
)
required=group.required)
# map the actions to their new mutex group
for action in group._group_actions:
@ -1469,10 +1416,8 @@ class _ActionsContainer(object):
for option_string in args:
# error on strings that don't start with an appropriate prefix
if not option_string[0] in self.prefix_chars:
msg = _(
'invalid option string %r: '
'must start with a character %r',
)
msg = _('invalid option string %r: '
'must start with a character %r')
tup = option_string, self.prefix_chars
raise ValueError(msg % tup)
@ -1528,11 +1473,9 @@ class _ActionsContainer(object):
def _handle_conflict_error(self, action, conflicting_actions):
message = _('conflicting option string(s): %s')
conflict_string = ', '.join([
option_string
for option_string, action
in conflicting_actions
])
conflict_string = ', '.join([option_string
for option_string, action
in conflicting_actions])
raise ArgumentError(action, message % conflict_string)
def _handle_conflict_resolve(self, action, conflicting_actions):
@ -1622,21 +1565,19 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
- add_help -- Add a -h/-help option
"""
def __init__(
self,
prog=None,
usage=None,
description=None,
epilog=None,
version=None,
parents=[],
formatter_class=HelpFormatter,
prefix_chars='-',
fromfile_prefix_chars=None,
argument_default=None,
conflict_handler='error',
add_help=True,
):
def __init__(self,
prog=None,
usage=None,
description=None,
epilog=None,
version=None,
parents=[],
formatter_class=HelpFormatter,
prefix_chars='-',
fromfile_prefix_chars=None,
argument_default=None,
conflict_handler='error',
add_help=True):
if version is not None:
import warnings
@ -1644,16 +1585,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
"""The "version" argument to ArgumentParser is deprecated. """
"""Please use """
""""add_argument(..., action='version', version="N", ...)" """
"""instead""", DeprecationWarning,
)
"""instead""", DeprecationWarning)
superinit = super(ArgumentParser, self).__init__
superinit(
description=description,
prefix_chars=prefix_chars,
argument_default=argument_default,
conflict_handler=conflict_handler,
)
superinit(description=description,
prefix_chars=prefix_chars,
argument_default=argument_default,
conflict_handler=conflict_handler)
# default setting for prog
if prog is None:
@ -1687,15 +1625,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
self.add_argument(
default_prefix + 'h', default_prefix * 2 + 'help',
action='help', default=SUPPRESS,
help=_('show this help message and exit'),
)
help=_('show this help message and exit'))
if self.version:
self.add_argument(
default_prefix + 'v', default_prefix * 2 + 'version',
action='version', default=SUPPRESS,
version=self.version,
help=_("show program's version number and exit"),
)
help=_("show program's version number and exit"))
# add parent arguments and defaults
for parent in parents:
@ -1764,18 +1700,14 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
return action
def _get_optional_actions(self):
return [
action
for action in self._actions
if action.option_strings
]
return [action
for action in self._actions
if action.option_strings]
def _get_positional_actions(self):
return [
action
for action in self._actions
if not action.option_strings
]
return [action
for action in self._actions
if not action.option_strings]
# =====================================
# Command line argument parsing methods
@ -1999,8 +1931,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
next_option_string_index = min([
index
for index in option_string_indices
if index >= start_index
])
if index >= start_index])
if start_index != next_option_string_index:
positionals_end_index = consume_positionals(start_index)
@ -2049,11 +1980,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# if no actions were used, report the error
else:
names = [
_get_action_name(action)
for action in group._group_actions
if action.help is not SUPPRESS
]
names = [_get_action_name(action)
for action in group._group_actions
if action.help is not SUPPRESS]
msg = _('one of the arguments %s is required')
self.error(msg % ' '.join(names))
@ -2117,10 +2046,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
result = []
for i in range(len(actions), 0, -1):
actions_slice = actions[:i]
pattern = ''.join([
self._get_nargs_pattern(action)
for action in actions_slice
])
pattern = ''.join([self._get_nargs_pattern(action)
for action in actions_slice])
match = _re.match(pattern, arg_strings_pattern)
if match is not None:
result.extend([len(string) for string in match.groups()])
@ -2161,8 +2088,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# if multiple actions match, the option string was ambiguous
if len(option_tuples) > 1:
options = ', '.join(
[option_string for action, option_string, explicit_arg in option_tuples],
)
[option_string for action, option_string, explicit_arg in option_tuples])
tup = arg_string, options
self.error(_('ambiguous option: %s could match %s') % tup)
@ -2292,10 +2218,8 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# when nargs='*' on a positional, if there were no command-line
# args, use the default if it is anything other than None
elif (
not arg_strings and action.nargs == ZERO_OR_MORE and
not action.option_strings
):
elif (not arg_strings and action.nargs == ZERO_OR_MORE and
not action.option_strings):
if action.default is not None:
value = action.default
else:
@ -2363,20 +2287,16 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
# =======================
def format_usage(self):
formatter = self._get_formatter()
formatter.add_usage(
self.usage, self._actions,
self._mutually_exclusive_groups,
)
formatter.add_usage(self.usage, self._actions,
self._mutually_exclusive_groups)
return formatter.format_help()
def format_help(self):
formatter = self._get_formatter()
# usage
formatter.add_usage(
self.usage, self._actions,
self._mutually_exclusive_groups,
)
formatter.add_usage(self.usage, self._actions,
self._mutually_exclusive_groups)
# description
formatter.add_text(self.description)
@ -2399,8 +2319,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
warnings.warn(
'The format_version method is deprecated -- the "version" '
'argument to ArgumentParser is no longer supported.',
DeprecationWarning,
)
DeprecationWarning)
formatter = self._get_formatter()
formatter.add_text(self.version)
return formatter.format_help()
@ -2426,8 +2345,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
warnings.warn(
'The print_version method is deprecated -- the "version" '
'argument to ArgumentParser is no longer supported.',
DeprecationWarning,
)
DeprecationWarning)
self._print_message(self.format_version(), file)
def _print_message(self, message, file=None):

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
@ -55,8 +55,7 @@ def load(config):
os.path.expanduser('~'),
'.local',
'share',
'autojump',
)
'autojump')
if is_osx() and os.path.exists(xdg_aj_home):
migrate_osx_xdg_data(config)
@ -76,14 +75,11 @@ def load(config):
with open(
config['data_path'],
'r', encoding='utf-8',
errors='replace',
) as f:
errors='replace') as f:
return dict(
imap(
tupleize,
ifilter(correct_length, imap(parse, f)),
),
)
ifilter(correct_length, imap(parse, f))))
except (IOError, EOFError):
return load_backup(config)
@ -120,12 +116,11 @@ def migrate_osx_xdg_data(config):
def save(config, data):
"""Save data and create backup, creating a new data file if necessary."""
data_dir = os.path.dirname(config['data_path'])
create_dir(data_dir)
create_dir(os.path.dirname(config['data_path']))
# atomically save by writing to temporary file and moving to destination
try:
temp = NamedTemporaryFile(delete=False, dir=data_dir)
temp = NamedTemporaryFile(delete=False)
# Windows cannot reuse the same open file name
temp.close()

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import os
import re
@ -117,13 +117,11 @@ def match_fuzzy(needles, haystack, ignore_case=False, threshold=0.6):
needle = last(needles).lower()
match_percent = lambda entry: SequenceMatcher(
a=needle,
b=end_dir(entry.path.lower()),
).ratio()
b=end_dir(entry.path.lower())).ratio()
else:
needle = last(needles)
match_percent = lambda entry: SequenceMatcher(
a=needle,
b=end_dir(entry.path),
).ratio()
b=end_dir(entry.path)).ratio()
meets_threshold = lambda entry: match_percent(entry) >= threshold
return ifilter(meets_threshold, haystack)

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
@ -56,8 +56,7 @@ def get_tab_entry_info(entry, separator):
match_index = re.search(separator + r'([0-9]{1})', entry)
match_path = re.search(
separator + r'[0-9]{1}' + separator + r'(.*)',
entry,
)
entry)
if match_needle:
needle = match_needle.group(1)
@ -164,9 +163,7 @@ def print_tab_menu(needle, tab_entries, separator):
separator,
i + 1,
separator,
entry.path,
),
)
entry.path))
def sanitize(directories):

View File

@ -3,15 +3,15 @@ setlocal EnableDelayedExpansion
echo %*|>nul findstr /rx \-.*
if ERRORLEVEL 1 (
for /f "delims=" %%i in ('python "%~dp0\autojump" %*') do set new_path=%%i
for /f %%i in ('python "%~dp0\autojump" %*') do set new_path=%%i
if exist !new_path!\nul (
echo !new_path!
pushd !new_path!
REM endlocal is necessary so that we can change directory for outside of this script
REM but will automatically popd. We mush pushd twice to work around this.
pushd !new_path!
endlocal
popd
pushd !new_path!
REM endlocal is necessary so that we can change directory for outside of this script
REM but will automatically popd. We mush pushd twice to work around this.
pushd !new_path!
endlocal
popd
) else (
echo autojump: directory %* not found
echo try `autojump --help` for more information

View File

@ -5,4 +5,4 @@ if ERRORLEVEL 1 (
"%~dp0\j.bat" "%cd%" %*
) else (
python "%~dp0\autojump" %*
)
)

View File

@ -5,4 +5,4 @@ if ERRORLEVEL 1 (
"%~dp0\jc.bat" "%cd%" %*
) else (
python "%~dp0\autojump" %*
)
)

View File

@ -3,13 +3,13 @@ setlocal EnableDelayedExpansion
echo %*|>nul findstr /rx \-.*
if ERRORLEVEL 1 (
for /f "delims=" %%i in ('python "%~dp0\autojump" %*') do set new_path=%%i
for /f %%i in ('python "%~dp0\autojump" %*') do set new_path=%%i
if exist !new_path!\nul (
start "" "explorer" !new_path!
start !new_path!
) else (
echo autojump: directory %* not found
echo try `autojump --help` for more information
)
) else (
python "%~dp0\autojump" %*
)
)

View File

@ -1,6 +1,6 @@
.\" Automatically generated by Pandoc 1.16.0.2
.\"
.TH "autojump" "1" "2018\-09\-09" "release\-v22.5.3" ""
.TH "autojump" "1" "10 April 2012" "release\-v22" ""
.hy
.SS NAME
.PP
@ -120,7 +120,7 @@ For any questions or issues please visit:
.IP
.nf
\f[C]
https://github.com/wting/autojump/issues
https://github.com/joelthelion/autojump/issues
\f[]
.fi
.SS AUTHORS

View File

@ -17,7 +17,7 @@ REPORTING BUGS
For any questions or issues please visit:
https://github.com/wting/autojump/issues
https://github.com/joelthelion/autojump/issues
AUTHORS
-------

View File

@ -2,59 +2,28 @@
### REQUIREMENTS
- Python v2.6+ or Python v3.3+
- Supported shells
- bash - first class support
- zsh - first class support
- fish - community supported
- tcsh - community supported
- clink - community supported
- Supported platforms
- Linux - first class support
- OS X - first class support
- Windows - community supported
- BSD - community supported
- Supported installation methods
- source code - first class support
- Debian and derivatives - first class support
- ArchLinux / Gentoo / openSUSE / RedHat and derivatives - community supported
- Homebrew / MacPorts - community supported
Due to limited time and resources, only "first class support" items will be
maintained by the primary committers. All "community supported" items will be
updated based on pull requests submitted by the general public.
Please continue opening issues and providing feedback for community supported
items since consolidating information helps other users troubleshoot and submit
enhancements and fixes.
### MANUAL
Grab a copy of autojump:
git clone git://github.com/wting/autojump.git
Run the installation script and follow on screen instructions.
cd autojump
./install.py or ./uninstall.py
- Python v2.6+ except v3.2
- Supported shells:
- bash v4.0+
- zsh
- fish
- tcsh (experimental)
- clink (Windows, experimental)
### AUTOMATIC
#### Linux
autojump is included in the following distro repositories, please use relevant
package management utilities to install (e.g. apt-get, yum, pacman, etc):
package management utilities to install (e.g. yum, apt-get, etc):
- Debian, Ubuntu, Linux Mint
- Debian testing/unstable, Ubuntu, Linux Mint
All Debian-derived distros require manual activation for policy reasons,
please see `/usr/share/doc/autojump/README.Debian`.
- RedHat, Fedora, CentOS
Install `autojump-zsh` for zsh, `autojump-fish` for fish, etc.
- RedHat, Fedora, CentOS (install `autojump-zsh` for zsh, `autojump-fish` for
fish, etc.)
- ArchLinux
- Gentoo
- Frugalware
@ -66,7 +35,7 @@ Homebrew is the recommended installation method for Mac OS X:
brew install autojump
MacPorts is also available:
MacPorts also available:
port install autojump
@ -74,3 +43,14 @@ MacPorts is also available:
Windows support is enabled by [clink](https://mridgers.github.io/clink/) which
should be installed prior to installing autojump.
### MANUAL
Grab a copy of autojump:
git clone git://github.com/joelthelion/autojump.git
Run the installation script and follow on screen instructions.
cd autojump
./install.py or ./uninstall.py

View File

@ -1,3 +1,3 @@
% autojump(1) release-v22.5.3
% autojump(1) release-v22
%
% 2018-09-09
% 10 April 2012

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
@ -45,8 +45,7 @@ def modify_autojump_lua(clink_dir, bin_dir, dryrun=False):
"""Prepend custom AUTOJUMP_BIN_DIR definition to autojump.lua"""
custom_install = "local AUTOJUMP_BIN_DIR = \"%s\"\n" % bin_dir.replace(
'\\',
'\\\\',
)
'\\\\')
clink_file = os.path.join(clink_dir, 'autojump.lua')
with open(clink_file, 'r') as f:
original = f.read()
@ -58,13 +57,11 @@ def parse_arguments(): # noqa
if platform.system() == 'Windows':
default_user_destdir = os.path.join(
os.getenv('LOCALAPPDATA', ''),
'autojump',
)
'autojump')
else:
default_user_destdir = os.path.join(
os.path.expanduser('~'),
'.autojump',
)
'.autojump')
default_user_prefix = ''
default_user_zshshare = 'functions'
default_system_destdir = '/'
@ -74,36 +71,28 @@ def parse_arguments(): # noqa
parser = ArgumentParser(
description='Installs autojump globally for root users, otherwise \
installs in current user\'s home directory.'
)
installs in current user\'s home directory.')
parser.add_argument(
'-n', '--dryrun', action='store_true', default=False,
help='simulate installation',
)
help='simulate installation')
parser.add_argument(
'-f', '--force', action='store_true', default=False,
help='skip root user, shell type, Python version checks',
)
help='skip root user, shell type, Python version checks')
parser.add_argument(
'-d', '--destdir', metavar='DIR', default=default_user_destdir,
help='set destination to DIR',
)
help='set destination to DIR')
parser.add_argument(
'-p', '--prefix', metavar='DIR', default=default_user_prefix,
help='set prefix to DIR',
)
help='set prefix to DIR')
parser.add_argument(
'-z', '--zshshare', metavar='DIR', default=default_user_zshshare,
help='set zsh share destination to DIR',
)
help='set zsh share destination to DIR')
parser.add_argument(
'-c', '--clinkdir', metavar='DIR', default=default_clink_dir,
help='set clink directory location to DIR (Windows only)',
)
help='set clink directory location to DIR (Windows only)')
parser.add_argument(
'-s', '--system', action='store_true', default=False,
help='install system wide for all users',
)
help='install system wide for all users')
args = parser.parse_args()
@ -113,24 +102,18 @@ def parse_arguments(): # noqa
sys.exit(1)
if args.system:
if platform.system() == 'Windows':
print(
'System-wide installation is not supported on Windows.',
file=sys.stderr,
)
print('System-wide installation is not supported on Windows.',
file=sys.stderr)
sys.exit(1)
elif os.geteuid() != 0:
print(
'Please rerun as root for system-wide installation.',
file=sys.stderr,
)
print('Please rerun as root for system-wide installation.',
file=sys.stderr)
sys.exit(1)
if platform.system() != 'Windows' \
and get_shell() not in SUPPORTED_SHELLS:
print(
'Unsupported shell: %s' % os.getenv('SHELL'),
file=sys.stderr,
)
print('Unsupported shell: %s' % os.getenv('SHELL'),
file=sys.stderr)
sys.exit(1)
if args.destdir != default_user_destdir \
@ -142,10 +125,8 @@ def parse_arguments(): # noqa
if args.system:
if args.custom_install:
print(
'Custom paths incompatible with --system option.',
file=sys.stderr,
)
print('Custom paths incompatible with --system option.',
file=sys.stderr)
sys.exit(1)
args.destdir = default_system_destdir

View File

@ -28,12 +28,10 @@ def j(path):
newpath = Popen(
cmd,
stdout=PIPE,
shell=False,
).communicate()[0].strip()
shell=False).communicate()[0].strip()
if newpath:
ip.magic('cd %s' % newpath.decode('utf-8'))
# remove from namespace
del j

View File

@ -1,4 +1,4 @@
#!/usr/bin/env python3
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from __future__ import print_function
@ -25,31 +25,24 @@ def parse_arguments():
default_clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink')
parser = ArgumentParser(
description='Uninstalls autojump.',
)
description='Uninstalls autojump.')
parser.add_argument(
'-n', '--dryrun', action='store_true', default=False,
help='simulate installation',
)
help='simulate installation')
parser.add_argument(
'-u', '--userdata', action='store_true', default=False,
help='delete user data',
)
help='delete user data')
parser.add_argument(
'-d', '--destdir', metavar='DIR',
help='custom destdir',
)
help='custom destdir')
parser.add_argument(
'-p', '--prefix', metavar='DIR', default='',
help='custom prefix',
)
help='custom prefix')
parser.add_argument(
'-z', '--zshshare', metavar='DIR', default='functions',
help='custom zshshare',
)
help='custom zshshare')
parser.add_argument(
'-c', '--clinkdir', metavar='DIR', default=default_clink_dir,
)
'-c', '--clinkdir', metavar='DIR', default=default_clink_dir)
return parser.parse_args()
@ -105,15 +98,13 @@ def remove_system_installation(dryrun=False):
default_prefix,
'share',
'man',
'man1',
)
'man1')
etc_dir = os.path.join(default_destdir, 'etc', 'profile.d')
share_dir = os.path.join(
default_destdir,
default_prefix,
'share',
'autojump',
)
'autojump')
zshshare_dir = os.path.join(default_destdir, default_zshshare)
if not os.path.exists(share_dir):
@ -122,10 +113,8 @@ def remove_system_installation(dryrun=False):
print('\nFound system installation...')
if os.geteuid() != 0:
print(
'Please rerun as root for system-wide uninstall, skipping...',
file=sys.stderr,
)
print('Please rerun as root for system-wide uninstall, skipping...',
file=sys.stderr)
return
rm(os.path.join(bin_dir, 'autojump'), dryrun)
@ -146,13 +135,11 @@ def remove_user_data(dryrun=False):
data_home = os.path.join(
os.path.expanduser('~'),
'Library',
'autojump',
)
'autojump')
elif platform.system() == 'Windows':
data_home = os.path.join(
os.getenv('APPDATA'),
'autojump',
)
'autojump')
else:
data_home = os.getenv(
'XDG_DATA_HOME',
@ -160,9 +147,7 @@ def remove_user_data(dryrun=False):
os.path.expanduser('~'),
'.local',
'share',
'autojump',
),
)
'autojump'))
if os.path.exists(data_home):
print('\nFound user data...')
@ -171,10 +156,8 @@ def remove_user_data(dryrun=False):
def remove_user_installation(dryrun=False):
if platform.system() == 'Windows':
default_destdir = os.path.join(
os.getenv('LOCALAPPDATA', ''),
'autojump',
)
default_destdir = os.path.join(os.getenv('LOCALAPPDATA', ''),
'autojump')
clink_dir = os.path.join(os.getenv('LOCALAPPDATA', ''), 'clink')
else:
default_destdir = os.path.join(os.path.expanduser('~'), '.autojump')