Skip to content

Commit

Permalink
Implements wting#126. Options passed to j will now be parsed. -s shor…
Browse files Browse the repository at this point in the history
…t 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.
  • Loading branch information
wting committed May 27, 2012
1 parent d194429 commit 32566eb
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -189,6 +189,8 @@ ADVANCED USAGE
KNOWN ISSUES
------------

- Does not support directories that begin with `-`.

- zsh (bug \#86)

Tab completion does not work.
Expand Down
4 changes: 2 additions & 2 deletions bin/autojump
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '__'
Expand Down Expand Up @@ -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')
Expand Down
8 changes: 5 additions & 3 deletions bin/autojump.bash
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
15 changes: 12 additions & 3 deletions bin/autojump.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down
4 changes: 3 additions & 1 deletion docs/autojump.1
Original file line number Diff line number Diff line change
Expand Up @@ -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[]
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion docs/body.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 32566eb

Please sign in to comment.