From 32566eb89d7a9672401793143c9be0516a65df7e Mon Sep 17 00:00:00 2001 From: William Ting Date: Sun, 27 May 2012 11:24:49 -1000 Subject: [PATCH] Implements #126. Options passed to j will now be parsed. -s short option for --stat added, jumpstat alias removed. Options passed to the `j` function will now be passed on autojump. As a result, directories beginning with `-` are no longer supported. A -s short alias for --stat is added. Instead of using jumpstat, use `j --stat` or `j -s` instead. --- README.md | 4 +++- bin/autojump | 4 ++-- bin/autojump.bash | 8 +++++--- bin/autojump.zsh | 15 ++++++++++++--- docs/autojump.1 | 4 +++- docs/body.md | 4 +++- 6 files changed, 28 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index f74adac..af74e07 100644 --- a/README.md +++ b/README.md @@ -131,7 +131,7 @@ Options must be passed to 'autojump' and not the 'j' wrapper function. --purge deletes database entries that no longer exist on system - --stat show database entries and their key weights + -s, --stat show database entries and their key weights --version show version information and exit @@ -189,6 +189,8 @@ ADVANCED USAGE KNOWN ISSUES ------------ +- Does not support directories that begin with `-`. + - zsh (bug \#86) Tab completion does not work. diff --git a/bin/autojump b/bin/autojump index b591827..1d3604b 100755 --- a/bin/autojump +++ b/bin/autojump @@ -29,7 +29,7 @@ import shutil import sys from tempfile import NamedTemporaryFile -VERSION = 'release-v20-7' +VERSION = 'release-v20-8' MAX_KEYWEIGHT = 1000 MAX_STORED_PATHS = 1000 COMPLETION_SEPARATOR = '__' @@ -235,7 +235,7 @@ def options(): help='used for bash tab completion') parser.add_argument('--purge', action="store_true", default=False, help='delete all database entries that no longer exist on system') - parser.add_argument('--stat', action="store_true", default=False, + parser.add_argument('-s', '--stat', action="store_true", default=False, help='show database entries and their key weights') parser.add_argument('--version', action="version", version="%(prog)s " + VERSION, help='show version information and exit') diff --git a/bin/autojump.bash b/bin/autojump.bash index 32f4466..93cde45 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -62,11 +62,13 @@ case $PROMPT_COMMAND in *) export PROMPT_COMMAND="$AUTOJUMP ; ${PROMPT_COMMAND:-:}";; esac -alias jumpstat="autojump --stat" - function j { - new_path="$(autojump $@)" + if [[ ${@} =~ -.* ]]; then + autojump ${@} + return + fi + new_path="$(autojump $@)" if [ -d "${new_path}" ]; then echo -e "\\033[31m${new_path}\\033[0m" cd "${new_path}" diff --git a/bin/autojump.zsh b/bin/autojump.zsh index 96ce02c..dde5bbf 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -41,11 +41,20 @@ function autojump_preexec() { typeset -ga preexec_functions preexec_functions+=autojump_preexec -alias jumpstat="autojump --stat" - function j { - local new_path="$(autojump $@)" + if is-at-least 4.3.5; then + if [[ ${@} =~ -.* ]]; then + autojump ${@} + return + fi + else + if [[ ${@} -pcre-match -.* ]]; then + autojump ${@} + return + fi + fi + local new_path="$(autojump $@)" if [ -d "${new_path}" ]; then echo -e "\\033[31m${new_path}\\033[0m" cd "${new_path}" diff --git a/docs/autojump.1 b/docs/autojump.1 index 3dc208c..2724f26 100644 --- a/docs/autojump.1 +++ b/docs/autojump.1 @@ -37,7 +37,7 @@ wrapper function. --purge\ \ \ \ \ \ \ \ \ \ \ \ \ deletes\ database\ entries\ that\ no\ longer\ exist\ on\ system ---stat\ \ \ \ \ \ \ \ \ \ \ \ \ \ show\ database\ entries\ and\ their\ key\ weights +-s,\ --stat\ \ \ \ \ \ \ \ \ \ \ \ \ \ show\ database\ entries\ and\ their\ key\ weights --version\ \ \ \ \ \ \ \ \ \ \ show\ version\ information\ and\ exit \f[] @@ -120,6 +120,8 @@ All negative key weights are purged automatically. .RE .SS KNOWN ISSUES .IP \[bu] 2 +Does not support directories that begin with \f[C]-\f[]. +.IP \[bu] 2 zsh (bug #86) .RS 2 .PP diff --git a/docs/body.md b/docs/body.md index 95be070..b4c8cc3 100644 --- a/docs/body.md +++ b/docs/body.md @@ -6,7 +6,7 @@ Options must be passed to 'autojump' and not the 'j' wrapper function. --purge deletes database entries that no longer exist on system - --stat show database entries and their key weights + -s, --stat show database entries and their key weights --version show version information and exit @@ -48,6 +48,8 @@ Options must be passed to 'autojump' and not the 'j' wrapper function. ## KNOWN ISSUES +- Does not support directories that begin with `-`. + - zsh (bug #86) Tab completion does not work.