From c103b091d47bf9005d9a708515287f19444bbfa3 Mon Sep 17 00:00:00 2001 From: Jocelyn Mallon Date: Mon, 3 Oct 2011 19:25:26 -0700 Subject: [PATCH] name change to 'zshmarks' to better represent that this comes from 'bash marks' added a new function to manually edit the ~/.bookmarks file, using whatever $EDITOR the use has registered --- plugins/go/_go | 4 -- plugins/zshmarks/_go | 4 ++ .../zshmarks.plugin.zsh} | 41 +++++++++++-------- 3 files changed, 27 insertions(+), 22 deletions(-) delete mode 100644 plugins/go/_go create mode 100644 plugins/zshmarks/_go rename plugins/{go/go.plugin.zsh => zshmarks/zshmarks.plugin.zsh} (58%) diff --git a/plugins/go/_go b/plugins/go/_go deleted file mode 100644 index 37006f964..000000000 --- a/plugins/go/_go +++ /dev/null @@ -1,4 +0,0 @@ -#compdef go -#autoload - -_arguments "1: :(`grep "|" $HOME/.zshbookmarks | cut -d\| -f2`)" \ No newline at end of file diff --git a/plugins/zshmarks/_go b/plugins/zshmarks/_go new file mode 100644 index 000000000..6c8fe693f --- /dev/null +++ b/plugins/zshmarks/_go @@ -0,0 +1,4 @@ +#compdef go +#autoload + +_arguments "1: :(`grep "|" $HOME/.bookmarks | cut -d\| -f2`)" \ No newline at end of file diff --git a/plugins/go/go.plugin.zsh b/plugins/zshmarks/zshmarks.plugin.zsh similarity index 58% rename from plugins/go/go.plugin.zsh rename to plugins/zshmarks/zshmarks.plugin.zsh index 10ca81204..45b9d1061 100644 --- a/plugins/go/go.plugin.zsh +++ b/plugins/zshmarks/zshmarks.plugin.zsh @@ -1,15 +1,15 @@ # ------------------------------------------------------------------------------ -# FILE: go.plugin.zsh +# FILE: zshmarks.plugin.zsh # DESCRIPTION: oh-my-zsh plugin file. # AUTHOR: Jocelyn Mallon (jocelyn.e.mallon@gmail.com) # VERSION: 1.0 # ------------------------------------------------------------------------------ -bookmarks_file="$HOME/.zshbookmarks" +bookmarks_file="$HOME/.bookmarks" # Create bookmarks_file it if it doesn't exist if [[ ! -f $bookmarks_file ]]; then - touch $bookmarks_file + touch $bookmarks_file fi function bookmark() { @@ -29,22 +29,27 @@ function bookmark() { } function go() { - bookmark_name=$1 - bookmark="$(grep "|$bookmark_name$" "$bookmarks_file")" - if [[ -z $bookmark ]]; then - echo "Invalid name, please provide a valid bookmark name. For example:" - echo " go foo" - echo - echo "To bookmark a folder, go to the folder then do this (naming the bookmark 'foo'):" - echo " bookmark foo" - else - dir="${bookmark%%|*}" - cd "${dir}" - dir="" - fi + bookmark_name=$1 + bookmark="$(grep "|$bookmark_name$" "$bookmarks_file")" + if [[ -z $bookmark ]]; then + echo "Invalid name, please provide a valid bookmark name. For example:" + echo " go foo" + echo + echo "To bookmark a folder, go to the folder then do this (naming the bookmark 'foo'):" + echo " bookmark foo" + else + dir="${bookmark%%|*}" + cd "${dir}" + dir="" + fi } # Show a list of the bookmarks -function bookmarksshow(){ - cat ~/.bookmarks | awk '{ printf "%-40s%-40s%s\n",$1,$2,$3}' FS=\| +function showmarks() { + cat ~/.bookmarks | awk '{ printf "%-40s%-40s%s\n",$1,$2,$3}' FS=\| +} + +# manually edit bookmarks +function editmarks() { + $EDITOR $bookmarks_file } \ No newline at end of file