Skip to content

Commit

Permalink
Implements wting#110: use 'export AUTOJUMP_IGNORE_CASE=1' to make aut…
Browse files Browse the repository at this point in the history
…ojump case insensitive
  • Loading branch information
wting committed May 7, 2012
1 parent d7cea40 commit 7882550
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 6 deletions.
13 changes: 11 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,22 @@ INTERNAL OPTIONS
ADVANCED USAGE
--------------

- Always Ignore Case

Default behavior is to prioritize exact matches over all else. For
example, `j foo` will prefer /foobar over /FooBar even if the latter
has a higher weight. To change this behavior and ignore case, add
the following environmental variable in your \~/.bashrc:

export AUTOJUMP_IGNORE_CASE=1

- Prefer Symbolic Links

Default behavior is to evaluate symbolic links into full paths as to
reduce duplicate entries in the database. However, some users prefer
a shorter working directory path in their shell prompt. To switch
behavior to prefer symbolic links, export the following
configuration in your \~/.bashrc:
behavior to prefer symbolic links, add the following environmental
variable in your \~/.bashrc:

export AUTOJUMP_KEEP_SYMLINKS=1

Expand Down
11 changes: 10 additions & 1 deletion bin/autojump
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@ MAX_STORED_PATHS = 1000
COMPLETION_SEPARATOR = '__'
ARGS = None

# load config from environmental variables
if 'AUTOJUMP_DATA_DIR' in os.environ:
CONFIG_DIR = os.environ.get('AUTOJUMP_DATA_DIR')
else:
xdg_data_dir = os.environ.get('XDG_DATA_HOME') or os.path.join(os.environ['HOME'], '.local', 'share')
CONFIG_DIR = os.path.join(xdg_data_dir, 'autojump')

if 'AUTOJUMP_IGNORE_CASE' in os.environ:
if os.environ.get('AUTOJUMP_IGNORE_CASE') == 1:
ALWAYS_IGNORE_CASE = True
else:
ALWAYS_IGNORE_CASE = False

if CONFIG_DIR == os.path.expanduser('~'):
DB_FILE = CONFIG_DIR + '/.autojump.txt'
else:
Expand Down Expand Up @@ -331,7 +338,9 @@ def shell_utility():
else:
max_matches = 1

results = find_matches(db, patterns, max_matches, False)
if not ALWAYS_IGNORE_CASE:
results = find_matches(db, patterns, max_matches, False)

# if no results, try ignoring case
if ARGS.complete or not results:
results = find_matches(db, patterns, max_matches, True)
Expand Down
20 changes: 18 additions & 2 deletions docs/autojump.1
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,31 @@ wrapper function.
.fi
.SS ADVANCED USAGE
.IP \[bu] 2
Always Ignore Case
.RS 2
.PP
Default behavior is to prioritize exact matches over all else.
For example, \f[C]j\ foo\f[] will prefer /foobar over /FooBar even if
the latter has a higher weight.
To change this behavior and ignore case, add the following environmental
variable in your ~/.bashrc:
.IP
.nf
\f[C]
export\ AUTOJUMP_IGNORE_CASE=1
\f[]
.fi
.RE
.IP \[bu] 2
Prefer Symbolic Links
.RS 2
.PP
Default behavior is to evaluate symbolic links into full paths as to
reduce duplicate entries in the database.
However, some users prefer a shorter working directory path in their
shell prompt.
To switch behavior to prefer symbolic links, export the following
configuration in your ~/.bashrc:
To switch behavior to prefer symbolic links, add the following
environmental variable in your ~/.bashrc:
.IP
.nf
\f[C]
Expand Down
8 changes: 7 additions & 1 deletion docs/body.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,15 @@ Options must be passed to 'autojump' and not the 'j' wrapper function.

## ADVANCED USAGE

- Always Ignore Case

Default behavior is to prioritize exact matches over all else. For example, `j foo` will prefer /foobar over /FooBar even if the latter has a higher weight. To change this behavior and ignore case, add the following environmental variable in your ~/.bashrc:

export AUTOJUMP_IGNORE_CASE=1

- Prefer Symbolic Links

Default behavior is to evaluate symbolic links into full paths as to reduce duplicate entries in the database. However, some users prefer a shorter working directory path in their shell prompt. To switch behavior to prefer symbolic links, export the following configuration in your ~/.bashrc:
Default behavior is to evaluate symbolic links into full paths as to reduce duplicate entries in the database. However, some users prefer a shorter working directory path in their shell prompt. To switch behavior to prefer symbolic links, add the following environmental variable in your ~/.bashrc:

export AUTOJUMP_KEEP_SYMLINKS=1

Expand Down

0 comments on commit 7882550

Please sign in to comment.