From de87ac00729f7eb8f9ab2d4db62f8f6b251ae658 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Antonio=20Hern=C3=A1ndez?= Date: Tue, 10 Apr 2012 09:29:11 +0200 Subject: [PATCH 1/7] Added new function to print out the help. --- bashmarks.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/bashmarks.sh b/bashmarks.sh index dff401c..8244aa3 100644 --- a/bashmarks.sh +++ b/bashmarks.sh @@ -73,6 +73,11 @@ function d { fi } +# print out the help +function h { + check_help "-h" +} + # print out help for the forgetful function check_help { if [ "$1" = "-h" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ] ; then @@ -82,6 +87,7 @@ function check_help { echo 'p - Prints the directory associated with "bookmark_name"' echo 'd - Deletes the bookmark' echo 'l - Lists all available bookmarks' + echo 'h - Shows this help' kill -SIGINT $$ fi } From f1eb1ea95e25755adffa1907954008f6c2cfe99d Mon Sep 17 00:00:00 2001 From: Alistair MacLeod Date: Sat, 30 Apr 2011 16:38:03 -0700 Subject: [PATCH 2/7] Spelling. --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f28d567..17c41b5 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ INSTALL_DIR=~/.local/bin all: - @echo "Pleas run 'make install'" + @echo "Please run 'make install'" install: @echo "" From e9332bdeb99e661edc04cd9c7f667fa43bc81143 Mon Sep 17 00:00:00 2001 From: Dave Harris Date: Wed, 27 Feb 2013 17:28:01 +1300 Subject: [PATCH 3/7] Added 'Moving to ' and ' does not exist' messages when using g. Change colour ouput of g from red to green (as not error) --- bashmarks.sh | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/bashmarks.sh b/bashmarks.sh index 8244aa3..26c1326 100644 --- a/bashmarks.sh +++ b/bashmarks.sh @@ -38,6 +38,9 @@ if [ ! -n "$SDIRS" ]; then fi touch $SDIRS +RED="0;31m" +GREEN="0;33m" + # save current directory to bookmarks function s { check_help $1 @@ -53,7 +56,13 @@ function s { function g { check_help $1 source $SDIRS - cd "$(eval $(echo echo $(echo \$DIR_$1)))" + target="$(eval $(echo echo $(echo \$DIR_$1)))" + if [ -n "$target" ]; then + echo -e "\033[${GREEN}Moving to ${target}\033[00m" + cd "$target" + else + echo -e "\033[${RED}${1} does not exist\033[00m" + fi } # print bookmark @@ -98,7 +107,7 @@ function l { source $SDIRS # if color output is not working for you, comment out the line below '\033[1;32m' == "red" - env | sort | awk '/DIR_.+/{split(substr($0,5),parts,"="); printf("\033[1;31m%-20s\033[0m %s\n", parts[1], parts[2]);}' + env | sort | awk '/DIR_.+/{split(substr($0,5),parts,"="); printf("\033[0;33m%-20s\033[0m %s\n", parts[1], parts[2]);}' # uncomment this line if color output is not working with the line above # env | grep "^DIR_" | cut -c5- | sort |grep "^.*=" From 47fc97c664228cc27ad2a3f16b6c8903cb02a50b Mon Sep 17 00:00:00 2001 From: huy Date: Sun, 5 May 2013 17:31:00 -0700 Subject: [PATCH 4/7] make sure to check that directory exists --- bashmarks.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bashmarks.sh b/bashmarks.sh index 26c1326..0275f22 100644 --- a/bashmarks.sh +++ b/bashmarks.sh @@ -57,8 +57,7 @@ function g { check_help $1 source $SDIRS target="$(eval $(echo echo $(echo \$DIR_$1)))" - if [ -n "$target" ]; then - echo -e "\033[${GREEN}Moving to ${target}\033[00m" + if [ -d "$target" ]; then cd "$target" else echo -e "\033[${RED}${1} does not exist\033[00m" From 62fc28ede893fad155208b050287ada91931a66e Mon Sep 17 00:00:00 2001 From: huy Date: Sun, 5 May 2013 17:34:55 -0700 Subject: [PATCH 5/7] print out directory if it does not exist --- bashmarks.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bashmarks.sh b/bashmarks.sh index 0275f22..64eac98 100644 --- a/bashmarks.sh +++ b/bashmarks.sh @@ -60,7 +60,7 @@ function g { if [ -d "$target" ]; then cd "$target" else - echo -e "\033[${RED}${1} does not exist\033[00m" + echo -e "\033[${RED}WARNING: '${target}' does not exist\033[00m" fi } From 40e25240e20d43d54b545faa20df4afffdbece05 Mon Sep 17 00:00:00 2001 From: huy Date: Sun, 5 May 2013 17:38:53 -0700 Subject: [PATCH 6/7] check for non existent bashmark --- bashmarks.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bashmarks.sh b/bashmarks.sh index 64eac98..450b015 100644 --- a/bashmarks.sh +++ b/bashmarks.sh @@ -59,6 +59,8 @@ function g { target="$(eval $(echo echo $(echo \$DIR_$1)))" if [ -d "$target" ]; then cd "$target" + elif [ ! -n "$target" ]; then + echo -e "\033[${RED}WARNING: '${1}' bashmark does not exist\033[00m" else echo -e "\033[${RED}WARNING: '${target}' does not exist\033[00m" fi From 021172b2670b6be93bd51e6bd410c8aa859992a1 Mon Sep 17 00:00:00 2001 From: huy Date: Sun, 5 May 2013 17:39:28 -0700 Subject: [PATCH 7/7] added license information --- LICENSE | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..617eff1 --- /dev/null +++ b/LICENSE @@ -0,0 +1,22 @@ +# Copyright (c) 2010, Huy Nguyen, http://www.huyng.com +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without modification, are permitted provided +# that the following conditions are met: +# +# * Redistributions of source code must retain the above copyright notice, this list of conditions +# and the following disclaimer. +# * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the +# following disclaimer in the documentation and/or other materials provided with the distribution. +# * Neither the name of Huy Nguyen nor the names of contributors +# may be used to endorse or promote products derived from this software without +# specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED +# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A +# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +# ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED +# TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING +# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. \ No newline at end of file