mirror of
https://github.com/ohmyzsh/ohmyzsh.git
synced 2025-12-26 02:12:33 +01:00
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
This commit is contained in:
parent
820a027d47
commit
c103b091d4
3 changed files with 27 additions and 22 deletions
|
|
@ -1,4 +0,0 @@
|
||||||
#compdef go
|
|
||||||
#autoload
|
|
||||||
|
|
||||||
_arguments "1: :(`grep "|" $HOME/.zshbookmarks | cut -d\| -f2`)"
|
|
||||||
4
plugins/zshmarks/_go
Normal file
4
plugins/zshmarks/_go
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
#compdef go
|
||||||
|
#autoload
|
||||||
|
|
||||||
|
_arguments "1: :(`grep "|" $HOME/.bookmarks | cut -d\| -f2`)"
|
||||||
|
|
@ -1,15 +1,15 @@
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
# FILE: go.plugin.zsh
|
# FILE: zshmarks.plugin.zsh
|
||||||
# DESCRIPTION: oh-my-zsh plugin file.
|
# DESCRIPTION: oh-my-zsh plugin file.
|
||||||
# AUTHOR: Jocelyn Mallon (jocelyn.e.mallon@gmail.com)
|
# AUTHOR: Jocelyn Mallon (jocelyn.e.mallon@gmail.com)
|
||||||
# VERSION: 1.0
|
# VERSION: 1.0
|
||||||
# ------------------------------------------------------------------------------
|
# ------------------------------------------------------------------------------
|
||||||
|
|
||||||
bookmarks_file="$HOME/.zshbookmarks"
|
bookmarks_file="$HOME/.bookmarks"
|
||||||
|
|
||||||
# Create bookmarks_file it if it doesn't exist
|
# Create bookmarks_file it if it doesn't exist
|
||||||
if [[ ! -f $bookmarks_file ]]; then
|
if [[ ! -f $bookmarks_file ]]; then
|
||||||
touch $bookmarks_file
|
touch $bookmarks_file
|
||||||
fi
|
fi
|
||||||
|
|
||||||
function bookmark() {
|
function bookmark() {
|
||||||
|
|
@ -29,22 +29,27 @@ function bookmark() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function go() {
|
function go() {
|
||||||
bookmark_name=$1
|
bookmark_name=$1
|
||||||
bookmark="$(grep "|$bookmark_name$" "$bookmarks_file")"
|
bookmark="$(grep "|$bookmark_name$" "$bookmarks_file")"
|
||||||
if [[ -z $bookmark ]]; then
|
if [[ -z $bookmark ]]; then
|
||||||
echo "Invalid name, please provide a valid bookmark name. For example:"
|
echo "Invalid name, please provide a valid bookmark name. For example:"
|
||||||
echo " go foo"
|
echo " go foo"
|
||||||
echo
|
echo
|
||||||
echo "To bookmark a folder, go to the folder then do this (naming the bookmark 'foo'):"
|
echo "To bookmark a folder, go to the folder then do this (naming the bookmark 'foo'):"
|
||||||
echo " bookmark foo"
|
echo " bookmark foo"
|
||||||
else
|
else
|
||||||
dir="${bookmark%%|*}"
|
dir="${bookmark%%|*}"
|
||||||
cd "${dir}"
|
cd "${dir}"
|
||||||
dir=""
|
dir=""
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Show a list of the bookmarks
|
# Show a list of the bookmarks
|
||||||
function bookmarksshow(){
|
function showmarks() {
|
||||||
cat ~/.bookmarks | awk '{ printf "%-40s%-40s%s\n",$1,$2,$3}' FS=\|
|
cat ~/.bookmarks | awk '{ printf "%-40s%-40s%s\n",$1,$2,$3}' FS=\|
|
||||||
|
}
|
||||||
|
|
||||||
|
# manually edit bookmarks
|
||||||
|
function editmarks() {
|
||||||
|
$EDITOR $bookmarks_file
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue