Skip to content

Commit

Permalink
Add install.zsh
Browse files Browse the repository at this point in the history
  • Loading branch information
calmzhu authored Dec 28, 2023
1 parent 9aad6db commit 3f43f73
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 7 deletions.
26 changes: 19 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,29 @@

## Description

A ohmyzsh plugin to support bookmark for directories in cmdline.
Yet another ohmyzsh plugin to quick jump between cmdline directories.

## Usage
1. Ensure both sed & awk are already installed in you cmdline PATH.
2. Install plugin to ohmyzsh customer plugin dir
3. Add **bookmark** to the plugins array in your zshrc file
`plugins=(... bookmark)`
And the design concern is very simple

Add path to bookmarks, return an ordered number.
and use the numbers to switch between dirs finally.

There are also lots of powerfull [FS Jumping](https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins-Overview#fs-jumping) plugins if this is too simple for your case.
But if you also prefer simple and intuitive solution. this plugin can also be a good alternative.


### Usage
## Install
1. Ensure both sed are already installed in you cmdline PATH.
1. Ensure [ohmyzsh](https://github.com/ohmyzsh/ohmyzsh) already installed.
1. Install plugin to ohmyzsh customer plugin dir.
```zsh
curl -s https://raw.githubusercontent.com/calmzhu/ohmyzsh-plugin-bookmark/main/install.zsh >install.zsh
zsh install.zsh $ZSH_CUSTOM
```
1. Add **bookmark** to the plugins array in your zshrc file.
`plugins=(... bookmark)`.

## Usage

```bash
$ l -a ~ #Add home dir to bookmark
Expand Down
26 changes: 26 additions & 0 deletions install.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

export ZSH_CUSTOM=$1

function error {
local _message=$1
echo -e "\033[31m$_message\033[0m"
exit 1
}

[[ `basename $SHELL` -eq "zsh" ]] || error "Please run in zsh"

export DOC_URL="https://github.com/calmzhu/ohmyzsh-plugin-bookmark/tree/main?tab=readme-ov-file#install"
export VERSION=latest

which sed>/dev/null || error "Cannot found sed in '\$PATH';see $DOC_URL"

export INSTALL_DIR="$ZSH_CUSTOM/plugins"
[[ -d "$INSTALL_DIR" ]] || error "Error: Cannot found zsh plugin dir '\$ZSH_CUSTOM/plugins';\nsee $DOC_URL"

download_url=`curl -s https://api.github.com/repos/calmzhu/ohmyzsh-plugin-bookmark/releases/$VERSION | \
grep "browser_download_url" | \
grep -o "http.*\.zip"`
temp=`mktemp`
curl -L $download_url --output $temp
unzip $temp -d $INSTALL_DIR
rm -rf $temp

0 comments on commit 3f43f73

Please sign in to comment.