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

Implements #110: use 'export AUTOJUMP_IGNORE_CASE=1' to make autojump case insensitive

This commit is contained in:
William Ting 2012-05-06 18:30:22 -10:00
parent d7cea40619
commit 788255030b
4 changed files with 46 additions and 6 deletions

View File

@ -130,13 +130,22 @@ INTERNAL OPTIONS
ADVANCED USAGE 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 - Prefer Symbolic Links
Default behavior is to evaluate symbolic links into full paths as to Default behavior is to evaluate symbolic links into full paths as to
reduce duplicate entries in the database. However, some users prefer reduce duplicate entries in the database. However, some users prefer
a shorter working directory path in their shell prompt. To switch a shorter working directory path in their shell prompt. To switch
behavior to prefer symbolic links, export the following behavior to prefer symbolic links, add the following environmental
configuration in your \~/.bashrc: variable in your \~/.bashrc:
export AUTOJUMP_KEEP_SYMLINKS=1 export AUTOJUMP_KEEP_SYMLINKS=1

View File

@ -15,12 +15,19 @@ MAX_STORED_PATHS = 1000
COMPLETION_SEPARATOR = '__' COMPLETION_SEPARATOR = '__'
ARGS = None ARGS = None
# load config from environmental variables
if 'AUTOJUMP_DATA_DIR' in os.environ: if 'AUTOJUMP_DATA_DIR' in os.environ:
CONFIG_DIR = os.environ.get('AUTOJUMP_DATA_DIR') CONFIG_DIR = os.environ.get('AUTOJUMP_DATA_DIR')
else: else:
xdg_data_dir = os.environ.get('XDG_DATA_HOME') or os.path.join(os.environ['HOME'], '.local', 'share') 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') 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('~'): if CONFIG_DIR == os.path.expanduser('~'):
DB_FILE = CONFIG_DIR + '/.autojump.txt' DB_FILE = CONFIG_DIR + '/.autojump.txt'
else: else:
@ -331,7 +338,9 @@ def shell_utility():
else: else:
max_matches = 1 max_matches = 1
if not ALWAYS_IGNORE_CASE:
results = find_matches(db, patterns, max_matches, False) results = find_matches(db, patterns, max_matches, False)
# if no results, try ignoring case # if no results, try ignoring case
if ARGS.complete or not results: if ARGS.complete or not results:
results = find_matches(db, patterns, max_matches, True) results = find_matches(db, patterns, max_matches, True)

View File

@ -53,6 +53,22 @@ wrapper function.
.fi .fi
.SS ADVANCED USAGE .SS ADVANCED USAGE
.IP \[bu] 2 .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 Prefer Symbolic Links
.RS 2 .RS 2
.PP .PP
@ -60,8 +76,8 @@ Default behavior is to evaluate symbolic links into full paths as to
reduce duplicate entries in the database. reduce duplicate entries in the database.
However, some users prefer a shorter working directory path in their However, some users prefer a shorter working directory path in their
shell prompt. shell prompt.
To switch behavior to prefer symbolic links, export the following To switch behavior to prefer symbolic links, add the following
configuration in your ~/.bashrc: environmental variable in your ~/.bashrc:
.IP .IP
.nf .nf
\f[C] \f[C]

View File

@ -18,9 +18,15 @@ Options must be passed to 'autojump' and not the 'j' wrapper function.
## ADVANCED USAGE ## 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 - 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 export AUTOJUMP_KEEP_SYMLINKS=1