From 971303bcde2574b1ae88c6b554bdb9adf9d37a4a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peltier?= Date: Thu, 23 Jul 2015 12:15:42 +0200 Subject: [PATCH 1/2] Add --child support to autojump. --- bin/autojump | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/bin/autojump b/bin/autojump index ed0151d..2508e62 100755 --- a/bin/autojump +++ b/bin/autojump @@ -120,6 +120,10 @@ def parse_arguments(): '--complete', action='store_true', default=False, help='used for tab completion', ) + parser.add_argument( + '--child', action="store_true", default=False, + help='only match subdirectories of the current working directory' + ) parser.add_argument( '--purge', action='store_true', default=False, help='remove non-existent paths from database', @@ -313,6 +317,13 @@ def main(args): # noqa tab_needle, tab_index, tab_path = \ get_tab_entry_info(first(needles), TAB_SEPARATOR) + if args.child: + pwd = get_pwd() + entries = ifilter( + lambda entry: entry.path.find(pwd) == 0, + entries + ) + # Handle `j foo__`, assuming first index. if not tab_path and not tab_index \ and tab_needle and needles[0] == tab_needle + TAB_SEPARATOR: From 9f0826dcf9c88fc0fb798b4413e2b92ebf08f53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Peltier?= Date: Thu, 23 Jul 2015 12:17:19 +0200 Subject: [PATCH 2/2] Add --child support to shell scripts. --- bin/autojump.bash | 8 ++++---- bin/autojump.fish | 14 ++------------ bin/autojump.zsh | 8 ++++---- 3 files changed, 10 insertions(+), 20 deletions(-) diff --git a/bin/autojump.bash b/bin/autojump.bash index 379e529..71db807 100644 --- a/bin/autojump.bash +++ b/bin/autojump.bash @@ -79,10 +79,10 @@ j() { # jump to child directory (subdirectory of current path) jc() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + autojump --child ${@} return else - j $(pwd) ${@} + j ${@} --child fi } @@ -122,9 +122,9 @@ jo() { # open autojump results (child directory) in file browser jco() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + autojump --child ${@} return else - jo $(pwd) ${@} + jo ${@} --child fi } diff --git a/bin/autojump.fish b/bin/autojump.fish index e995506..fb5ec76 100644 --- a/bin/autojump.fish +++ b/bin/autojump.fish @@ -70,12 +70,7 @@ end # jump to child directory (subdirectory of current path) function jc - switch "$argv" - case '-*' - j $argv - case '*' - j (pwd) $argv - end + j $argv --child end @@ -103,10 +98,5 @@ end # open autojump results (child directory) in file browser function jco - switch "$argv" - case '-*' - j $argv - case '*' - jo (pwd) $argv - end + jo $argv --child end diff --git a/bin/autojump.zsh b/bin/autojump.zsh index a761206..3596ffe 100644 --- a/bin/autojump.zsh +++ b/bin/autojump.zsh @@ -73,10 +73,10 @@ j() { # jump to child directory (subdirectory of current path) jc() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + autojump --child ${@} return else - j $(pwd) ${@} + j ${@} --child fi } @@ -117,9 +117,9 @@ jo() { # open autojump results (child directory) in file browser jco() { if [[ ${1} == -* ]] && [[ ${1} != "--" ]]; then - autojump ${@} + autojump --child ${@} return else - jo $(pwd) ${@} + jo ${@} --child fi }