Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add short form of '-g' option to bashmarks plugin #41

Merged
merged 1 commit into from
Jul 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion plugins/bashmarks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ You can navigate to the location of a bookmark using the *bm -g* command:

`$ bm -g mydir`

You can also supply just any bookmark name and the *-g* option will be assumed:

`$ bm mydir`

Tab completion is available when you need to enter a bookmark name in a command, such as when using *bm -g*

Easily list all bookmarks you have setup using the *bm -l* command.
Expand All @@ -24,7 +28,7 @@ Easily list all bookmarks you have setup using the *bm -l* command.

**bm -a bookmarkname** Save the current directory as bookmarkname

**bm -g bookmarkname** Go to the specified bookmark
**bm [-g] bookmarkname** Go to the specified bookmark

**bm -p bookmarkname** Print the bookmark

Expand Down
35 changes: 27 additions & 8 deletions plugins/bashmarks/bashmarks.plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -67,19 +67,38 @@ function bm {
_list_bookmark
;;
# help [ bm -h ]
-h)
_echo_usage
;;
*)
echo 'USAGE:'
echo 'bm -a <bookmark_name> - Saves the current directory as "bookmark_name"'
echo 'bm -g <bookmark_name> - Goes (cd) to the directory associated with "bookmark_name"'
echo 'bm -p <bookmark_name> - Prints the directory associated with "bookmark_name"'
echo 'bm -d <bookmark_name> - Deletes the bookmark'
echo 'bm -l - Lists all available bookmarks'
kill -SIGINT $$
exit 1
if [[ $1 == -* ]]; then
# unrecognized option. echo error message and usage [ bm -X ]
echo "Unknown option '$1'"
_echo_usage
kill -SIGINT $$
exit 1
elif [[ $1 == "" ]]; then
# no args supplied - echo usage [ bm ]
_echo_usage
else
# non-option supplied as first arg. assume goto [ bm BOOKMARK_NAME ]
_goto_bookmark "$1"
fi
;;
esac
}

# print usage information
function _echo_usage {
echo 'USAGE:'
echo "bm -h - Prints this usage info"
echo 'bm -a <bookmark_name> - Saves the current directory as "bookmark_name"'
echo 'bm [-g] <bookmark_name> - Goes (cd) to the directory associated with "bookmark_name"'
echo 'bm -p <bookmark_name> - Prints the directory associated with "bookmark_name"'
echo 'bm -d <bookmark_name> - Deletes the bookmark'
echo 'bm -l - Lists all available bookmarks'
}

# save current directory to bookmarks
function _save_bookmark {
_bookmark_name_valid "$@"
Expand Down