From 930753ddbe175540d102f01d099ca72f39b74982 Mon Sep 17 00:00:00 2001 From: Charles Thorley Date: Thu, 12 Dec 2013 18:18:16 -0800 Subject: [PATCH 1/3] Bug fixes --- plugins/jump/mark.fish | 3 ++- plugins/jump/marks.fish | 31 ++++++++++++++++++------------- 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/plugins/jump/mark.fish b/plugins/jump/mark.fish index d0546f4..5f23f41 100644 --- a/plugins/jump/mark.fish +++ b/plugins/jump/mark.fish @@ -3,9 +3,10 @@ function mark command ln -s (pwd) $MARKPATH/$argv[1] else if test (count $argv) -eq 2 if test -d $argv[2] + set -l current_dir (pwd) cd $argv[2] command ln -s (pwd) $MARKPATH/$argv[1] - cd - + cd $current_dir else echo "$argv[2] is not a valid directory." end diff --git a/plugins/jump/marks.fish b/plugins/jump/marks.fish index 07a3597..e658bbf 100644 --- a/plugins/jump/marks.fish +++ b/plugins/jump/marks.fish @@ -2,21 +2,26 @@ function marks if test (count $argv) -gt 0 echo "Usage: marks" else - set -l file_list (command ls $MARKPATH/) - set -l mark_list - for file in $file_list - if test -d $MARKPATH/$file -a -L $MARKPATH/$file - set mark_list $mark_list $file - end - end - if test (count $mark_list) -eq 0 + set -l file_list (command ls $MARKPATH) + if test (count $file_list) -eq 0 echo "No marks currently defined." else - for mark_name in $mark_list - cd $MARKPATH/$mark_name - set -l real_path (pwd) - cd - - echo "$mark_name -> $real_path" + set -l mark_list + for file in $file_list + if test -d $MARKPATH/$file -a -L $MARKPATH/$file + set mark_list $mark_list $file + end + end + if test (count $mark_list) -eq 0 + echo "No marks currently defined." + else + set -l current_dir (pwd) + for mark_name in $mark_list + cd $MARKPATH/$mark_name + set -l real_path (pwd) + echo "$mark_name -> $real_path" + end + cd $current_dir end end end From 7960f780191c565a546addc9ab1fb04f9048a1d7 Mon Sep 17 00:00:00 2001 From: Charles Thorley Date: Fri, 13 Dec 2013 18:10:13 -0800 Subject: [PATCH 2/3] Additional gatekeeping --- plugins/jump/mark.fish | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/plugins/jump/mark.fish b/plugins/jump/mark.fish index 5f23f41..7a228db 100644 --- a/plugins/jump/mark.fish +++ b/plugins/jump/mark.fish @@ -1,5 +1,13 @@ function mark - if test (count $argv) -eq 1 + if test (count $argv) -eq 0 -o (count $argv) -gt 2 + echo "Usage: mark [DIRECTORY]" + else if test -e $MARKPATH/$argv[1] + if test -d $MARKPATH/$argv[1] -a -L $MARKPATH/$argv[1] + echo "A mark named $argv[1] already exists." + else + echo "$MARKPATH/$argv[1] already exists." + end + else if test (count $argv) -eq 1 command ln -s (pwd) $MARKPATH/$argv[1] else if test (count $argv) -eq 2 if test -d $argv[2] @@ -10,7 +18,5 @@ function mark else echo "$argv[2] is not a valid directory." end - else - echo "Usage: mark [DIRECTORY]" end end From e0dc54480adb16229d0e79dfffef04200fc23214 Mon Sep 17 00:00:00 2001 From: Charles Thorley Date: Thu, 9 Jan 2014 20:30:20 -0800 Subject: [PATCH 3/3] Two-space indentation --- plugins/jump/jump.fish | 14 ++++++------ plugins/jump/jump.load | 2 +- plugins/jump/mark.fish | 38 ++++++++++++++++----------------- plugins/jump/marks.fish | 46 ++++++++++++++++++++-------------------- plugins/jump/unmark.fish | 20 ++++++++--------- 5 files changed, 60 insertions(+), 60 deletions(-) diff --git a/plugins/jump/jump.fish b/plugins/jump/jump.fish index dbfc73c..b054c36 100644 --- a/plugins/jump/jump.fish +++ b/plugins/jump/jump.fish @@ -1,11 +1,11 @@ function jump - if test (count $argv) -ne 1 - echo "Usage: jump " + if test (count $argv) -ne 1 + echo "Usage: jump " + else + if test -d $MARKPATH/$argv[1] -a -L $MARKPATH/$argv[1] + cd $MARKPATH/$argv[1] else - if test -d $MARKPATH/$argv[1] -a -L $MARKPATH/$argv[1] - cd $MARKPATH/$argv[1] - else - echo "No such mark: $argv[1]" - end + echo "No such mark: $argv[1]" end + end end diff --git a/plugins/jump/jump.load b/plugins/jump/jump.load index 8707c13..20081b5 100644 --- a/plugins/jump/jump.load +++ b/plugins/jump/jump.load @@ -1,2 +1,2 @@ -set -x MARKPATH $HOME/.marks +set -gx MARKPATH $HOME/.marks command mkdir -p $MARKPATH diff --git a/plugins/jump/mark.fish b/plugins/jump/mark.fish index 7a228db..6c175a8 100644 --- a/plugins/jump/mark.fish +++ b/plugins/jump/mark.fish @@ -1,22 +1,22 @@ function mark - if test (count $argv) -eq 0 -o (count $argv) -gt 2 - echo "Usage: mark [DIRECTORY]" - else if test -e $MARKPATH/$argv[1] - if test -d $MARKPATH/$argv[1] -a -L $MARKPATH/$argv[1] - echo "A mark named $argv[1] already exists." - else - echo "$MARKPATH/$argv[1] already exists." - end - else if test (count $argv) -eq 1 - command ln -s (pwd) $MARKPATH/$argv[1] - else if test (count $argv) -eq 2 - if test -d $argv[2] - set -l current_dir (pwd) - cd $argv[2] - command ln -s (pwd) $MARKPATH/$argv[1] - cd $current_dir - else - echo "$argv[2] is not a valid directory." - end + if test (count $argv) -eq 0 -o (count $argv) -gt 2 + echo "Usage: mark [DIRECTORY]" + else if test -e $MARKPATH/$argv[1] + if test -d $MARKPATH/$argv[1] -a -L $MARKPATH/$argv[1] + echo "A mark named $argv[1] already exists." + else + echo "$MARKPATH/$argv[1] already exists." end + else if test (count $argv) -eq 1 + command ln -s (pwd) $MARKPATH/$argv[1] + else if test (count $argv) -eq 2 + if test -d $argv[2] + set -l current_dir (pwd) + cd $argv[2] + command ln -s (pwd) $MARKPATH/$argv[1] + cd $current_dir + else + echo "$argv[2] is not a valid directory." + end + end end diff --git a/plugins/jump/marks.fish b/plugins/jump/marks.fish index e658bbf..9787e2f 100644 --- a/plugins/jump/marks.fish +++ b/plugins/jump/marks.fish @@ -1,28 +1,28 @@ function marks - if test (count $argv) -gt 0 - echo "Usage: marks" + if test (count $argv) -gt 0 + echo "Usage: marks" + else + set -l file_list (command ls $MARKPATH) + if test (count $file_list) -eq 0 + echo "No marks currently defined." else - set -l file_list (command ls $MARKPATH) - if test (count $file_list) -eq 0 - echo "No marks currently defined." - else - set -l mark_list - for file in $file_list - if test -d $MARKPATH/$file -a -L $MARKPATH/$file - set mark_list $mark_list $file - end - end - if test (count $mark_list) -eq 0 - echo "No marks currently defined." - else - set -l current_dir (pwd) - for mark_name in $mark_list - cd $MARKPATH/$mark_name - set -l real_path (pwd) - echo "$mark_name -> $real_path" - end - cd $current_dir - end + set -l mark_list + for file in $file_list + if test -d $MARKPATH/$file -a -L $MARKPATH/$file + set mark_list $mark_list $file end + end + if test (count $mark_list) -eq 0 + echo "No marks currently defined." + else + set -l current_dir (pwd) + for mark_name in $mark_list + cd $MARKPATH/$mark_name + set -l real_path (pwd) + echo "$mark_name -> $real_path" + end + cd $current_dir + end end + end end diff --git a/plugins/jump/unmark.fish b/plugins/jump/unmark.fish index a383b19..8965e1c 100644 --- a/plugins/jump/unmark.fish +++ b/plugins/jump/unmark.fish @@ -1,13 +1,13 @@ function unmark - if test (count $argv) -eq 0 - echo "Usage: unmark ..." - else - for mark_name in $argv - if test -d $MARKPATH/$mark_name -a -L $MARKPATH/$mark_name - command rm -i $MARKPATH/$mark_name - else - echo "No such mark: $mark_name" - end - end + if test (count $argv) -eq 0 + echo "Usage: unmark ..." + else + for mark_name in $argv + if test -d $MARKPATH/$mark_name -a -L $MARKPATH/$mark_name + command rm -i $MARKPATH/$mark_name + else + echo "No such mark: $mark_name" + end end + end end