From 9ad889a706229e3d7097c1f25006ee49a8db5c76 Mon Sep 17 00:00:00 2001 From: William Ting Date: Sun, 6 May 2012 18:40:19 -1000 Subject: [PATCH] To prevent database decay, set the env var AUTOJUMP_KEEP_ALL_ENTRIES=1 instead of using --preserve or --competion --- README.md | 18 ++++++++++++++---- bin/autojump | 12 ++++++++---- docs/autojump.1 | 20 +++++++++++++++++--- docs/body.md | 12 +++++++++--- 4 files changed, 48 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index ad5e41c..65d6322 100644 --- a/README.md +++ b/README.md @@ -114,8 +114,6 @@ Options must be passed to 'autojump' and not the 'j' wrapper function. -a, --add DIR manually add path to database - --preserve prevent key weight decay over time - --stat show database entries and their key weights --version show version information and exit @@ -127,8 +125,8 @@ INTERNAL OPTIONS --complete used for tab completion -ADVANCED USAGE --------------- +ADDITIONAL CONFIGURATION +------------------------ - Always Ignore Case @@ -139,6 +137,15 @@ ADVANCED USAGE export AUTOJUMP_IGNORE_CASE=1 +- Prevent Database Entries' Decay + + Default behavior is to decay unused database entries slowly over + time. Eventually when database limits are hit and maintenance is + run, autojump will purge older less used entries. To prevent decay, + add the following variable in your \~/.bashrc: + + export AUTOJUMP_KEEP_ALL_ENTRIES=1 + - Prefer Symbolic Links Default behavior is to evaluate symbolic links into full paths as to @@ -149,6 +156,9 @@ ADVANCED USAGE export AUTOJUMP_KEEP_SYMLINKS=1 +ADVANCED USAGE +-------------- + - Change Directory Weight To manually change a directory's key weight, you can edit the file diff --git a/bin/autojump b/bin/autojump index 4478269..90ad8c2 100755 --- a/bin/autojump +++ b/bin/autojump @@ -22,6 +22,12 @@ 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_KEEP_ALL_ENTRIES' in os.environ: + if os.environ.get('AUTOJUMP_KEEP_ALL_ENTRIES') == 1: + KEEP_ALL_ENTRIES = True + else: + KEEP_ALL_ENTRIES = False + if 'AUTOJUMP_IGNORE_CASE' in os.environ: if os.environ.get('AUTOJUMP_IGNORE_CASE') == 1: ALWAYS_IGNORE_CASE = True @@ -165,8 +171,6 @@ def options(): help='enclose directory quotes to prevent errors') parser.add_argument('--complete', action="store_true", default=False, help='used for bash tab completion') - parser.add_argument('--preserve', action="store_true", default=False, - help='prevent key weight decay over time') parser.add_argument('--stat', action="store_true", default=False, help='show database entries and their key weights') parser.add_argument('--version', action="version", version="%(prog)s " + VERSION, @@ -227,7 +231,7 @@ def match_last(pattern): if (len(last_pattern_path) > 0 and last_pattern_path[0] == "/" and os.path.exists(last_pattern_path)): - if not ARGS.preserve: + if not ARGS.complete: output(last_pattern_path) return True return False @@ -364,7 +368,7 @@ def shell_utility(): else: return False - if not ARGS.preserve: + if not KEEP_ALL_ENTRIES: db.maintenance() return True diff --git a/docs/autojump.1 b/docs/autojump.1 index 4845344..22c569d 100644 --- a/docs/autojump.1 +++ b/docs/autojump.1 @@ -35,8 +35,6 @@ wrapper function. \f[C] -a,\ --add\ DIR\ \ \ \ \ \ \ manually\ add\ path\ to\ database ---preserve\ \ \ \ \ \ \ \ \ \ prevent\ key\ weight\ decay\ over\ time - --stat\ \ \ \ \ \ \ \ \ \ \ \ \ \ show\ database\ entries\ and\ their\ key\ weights --version\ \ \ \ \ \ \ \ \ \ \ show\ version\ information\ and\ exit @@ -51,7 +49,7 @@ wrapper function. --complete\ \ \ \ \ \ \ \ \ \ used\ for\ tab\ completion \f[] .fi -.SS ADVANCED USAGE +.SS ADDITIONAL CONFIGURATION .IP \[bu] 2 Always Ignore Case .RS 2 @@ -69,6 +67,21 @@ export\ AUTOJUMP_IGNORE_CASE=1 .fi .RE .IP \[bu] 2 +Prevent Database Entries\[aq] Decay +.RS 2 +.PP +Default behavior is to decay unused database entries slowly over time. +Eventually when database limits are hit and maintenance is run, autojump +will purge older less used entries. +To prevent decay, add the following variable in your ~/.bashrc: +.IP +.nf +\f[C] +export\ AUTOJUMP_KEEP_ALL_ENTRIES=1 +\f[] +.fi +.RE +.IP \[bu] 2 Prefer Symbolic Links .RS 2 .PP @@ -85,6 +98,7 @@ export\ AUTOJUMP_KEEP_SYMLINKS=1 \f[] .fi .RE +.SS ADVANCED USAGE .IP \[bu] 2 Change Directory Weight .RS 2 diff --git a/docs/body.md b/docs/body.md index 708f7e5..331bc87 100644 --- a/docs/body.md +++ b/docs/body.md @@ -4,8 +4,6 @@ Options must be passed to 'autojump' and not the 'j' wrapper function. -a, --add DIR manually add path to database - --preserve prevent key weight decay over time - --stat show database entries and their key weights --version show version information and exit @@ -16,7 +14,7 @@ Options must be passed to 'autojump' and not the 'j' wrapper function. --complete used for tab completion -## ADVANCED USAGE +## ADDITIONAL CONFIGURATION - Always Ignore Case @@ -24,12 +22,20 @@ Options must be passed to 'autojump' and not the 'j' wrapper function. export AUTOJUMP_IGNORE_CASE=1 +- Prevent Database Entries' Decay + + Default behavior is to decay unused database entries slowly over time. Eventually when database limits are hit and maintenance is run, autojump will purge older less used entries. To prevent decay, add the following variable in your ~/.bashrc: + + export AUTOJUMP_KEEP_ALL_ENTRIES=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, add the following environmental variable in your ~/.bashrc: export AUTOJUMP_KEEP_SYMLINKS=1 +## ADVANCED USAGE + - Change Directory Weight To manually change a directory's key weight, you can edit the file _$XDG_DATA_HOME/autojump/autojump.txt_. Each entry has two columns. The first is the key weight and the second is the path: