From 788255030ba1c13c39f238b461f11ea74f4c509a Mon Sep 17 00:00:00 2001 From: William Ting Date: Sun, 6 May 2012 18:30:22 -1000 Subject: [PATCH] Implements #110: use 'export AUTOJUMP_IGNORE_CASE=1' to make autojump case insensitive --- README.md | 13 +++++++++++-- bin/autojump | 11 ++++++++++- docs/autojump.1 | 20 ++++++++++++++++++-- docs/body.md | 8 +++++++- 4 files changed, 46 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8ac14a2..ad5e41c 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bin/autojump b/bin/autojump index b599d49..4478269 100755 --- a/bin/autojump +++ b/bin/autojump @@ -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: @@ -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) diff --git a/docs/autojump.1 b/docs/autojump.1 index d63642c..4845344 100644 --- a/docs/autojump.1 +++ b/docs/autojump.1 @@ -53,6 +53,22 @@ 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 @@ -60,8 +76,8 @@ 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] diff --git a/docs/body.md b/docs/body.md index d6bef30..708f7e5 100644 --- a/docs/body.md +++ b/docs/body.md @@ -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