From 32b1b42f2c3cfc8e61ab20f93012b84d761de01d Mon Sep 17 00:00:00 2001 From: Alexandre Beaulieu Date: Mon, 30 Sep 2019 14:09:35 -0400 Subject: [PATCH 1/5] feat: Add oh-my-zsh plugin compatibility. --- navi.plugin.zsh | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 navi.plugin.zsh diff --git a/navi.plugin.zsh b/navi.plugin.zsh new file mode 100644 index 0000000..be75f17 --- /dev/null +++ b/navi.plugin.zsh @@ -0,0 +1,13 @@ +local _navi_path=$(dirname $0:A) + +_call_navi() { + local buff="$BUFFER" + zle kill-whole-line + local cmd="$(NAVI_USE_FZF_ALL_INPUTS=true $_navi_path/navi --print <> /dev/tty)" + zle -U "${buff}${cmd}" + # zle accept-line +} + +zle -N _call_navi + +bindkey '\eg' _call_navi From 507bd277a928e60dc0314b4c0bce13d7e89b2d58 Mon Sep 17 00:00:00 2001 From: Alexandre Beaulieu Date: Mon, 30 Sep 2019 14:18:52 -0400 Subject: [PATCH 2/5] doc: Added oh-my-zsh installation instructions. --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index ead7ef0..07906e0 100644 --- a/README.md +++ b/README.md @@ -58,6 +58,37 @@ sudo make install # install fzf: https://github.com/junegunn/fzf ``` +### Using oh-my-zsh + +Make sure that your oh-my-zsh `ZSH_CUSTOM` directory is configured, +then clone navi into the plugins directory. + +```sh +export ZSH_CUSTOM='/path/to/.zsh' + +DST="$ZSH_CUSTOM/plugins" +mkdir -p "$DST" && cd "$DST" +git clone http://github.com/denisidoro/navi +``` + +To enable navi, simply add it to the oh-my-zsh plugin array: + +``` +# Sample ~/.zshrc +ZSHCFG="$HOME/.zsh" +ZSH="$ZSHCFG/oh-my-zsh" +ZSH_CUSTOM="$ZSHCFG" +plugins=(archlinux docker compleat git github gpg-agent ssh-agent nvm tmux fzf workon navi) +# ... +source "$ZSH/oh-my-zsh.sh" +``` + +Then use it with `Alt-G`. + +This method has the following advantages: +- No PATH modification +- No root install required + Upgrading --------- From 286cb9f97f8c3215f9ce20e998a710afa195bd44 Mon Sep 17 00:00:00 2001 From: Alexandre Beaulieu Date: Tue, 1 Oct 2019 17:41:34 -0400 Subject: [PATCH 3/5] doc: code review changes. --- README.md | 25 +++++++++++-------------- shell/widget.zsh | 11 ----------- src/main.sh | 4 ++-- 3 files changed, 13 insertions(+), 27 deletions(-) delete mode 100644 shell/widget.zsh diff --git a/README.md b/README.md index 07906e0..9fb25be 100644 --- a/README.md +++ b/README.md @@ -52,42 +52,38 @@ brew install denisidoro/tools/navi Alternatively, you can `git clone` this repository and run `make`: ```sh -git clone --depth 1 http://github.com/denisidoro/navi /opt/navi +git clone --depth 1 https://github.com/denisidoro/navi /opt/navi cd /opt/navi sudo make install # install fzf: https://github.com/junegunn/fzf ``` + ### Using oh-my-zsh -Make sure that your oh-my-zsh `ZSH_CUSTOM` directory is configured, -then clone navi into the plugins directory. - +Make sure that your oh-my-zsh `$ZSH_CUSTOM` directory is configured, then clone navi into the plugins directory. ```sh export ZSH_CUSTOM='/path/to/.zsh' - DST="$ZSH_CUSTOM/plugins" -mkdir -p "$DST" && cd "$DST" -git clone http://github.com/denisidoro/navi +mkdir -p "$DST" +cd "$DST" +git clone https://github.com/denisidoro/navi ``` -To enable navi, simply add it to the oh-my-zsh plugin array: - +Then, add it to the oh-my-zsh plugin array: ``` # Sample ~/.zshrc ZSHCFG="$HOME/.zsh" ZSH="$ZSHCFG/oh-my-zsh" ZSH_CUSTOM="$ZSHCFG" -plugins=(archlinux docker compleat git github gpg-agent ssh-agent nvm tmux fzf workon navi) +plugins=(docker tmux fzf navi) # ... source "$ZSH/oh-my-zsh.sh" ``` -Then use it with `Alt-G`. +Finally, you can use it as a [shell widget](#shell-widget). -This method has the following advantages: -- No PATH modification -- No root install required +This method has the advantage of not requiring root to install and disadvantage of not allowing you to invoke the script by calling `navi` (unless you add an alias to it or copy it to a folder in `$PATH`). Upgrading --------- @@ -96,6 +92,7 @@ Upgrading - brew: `brew update; brew reinstall navi` - git: `cd /opt/navi && sudo make update` +- oh-my-zsh: `cd "$(navi home)" && sudo make update` Usage ----- diff --git a/shell/widget.zsh b/shell/widget.zsh deleted file mode 100644 index 2a1a83d..0000000 --- a/shell/widget.zsh +++ /dev/null @@ -1,11 +0,0 @@ -_call_navi() { - local buff="$BUFFER" - zle kill-whole-line - local cmd="$(NAVI_USE_FZF_ALL_INPUTS=true navi --print <> /dev/tty)" - zle -U "${buff}${cmd}" - # zle accept-line -} - -zle -N _call_navi - -bindkey '\eg' _call_navi \ No newline at end of file diff --git a/src/main.sh b/src/main.sh index 88e49a4..b95a786 100644 --- a/src/main.sh +++ b/src/main.sh @@ -97,7 +97,7 @@ handler::widget() { local widget case "$SH" in - zsh) widget="${SCRIPT_DIR}/shell/widget.zsh" ;; + zsh) widget="${SCRIPT_DIR}/navi.plugin.zsh" ;; *) echoerr "Invalid shell: $SH"; exit 1 ;; esac @@ -144,4 +144,4 @@ main() { handler::main ;; esac -} \ No newline at end of file +} From f6f643cec2f1c85be8eec6210b3d661648312252 Mon Sep 17 00:00:00 2001 From: Alexandre Beaulieu Date: Tue, 1 Oct 2019 17:46:56 -0400 Subject: [PATCH 4/5] fix: renamed DST to plugins_dir. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 9fb25be..7a61600 100644 --- a/README.md +++ b/README.md @@ -64,9 +64,9 @@ sudo make install Make sure that your oh-my-zsh `$ZSH_CUSTOM` directory is configured, then clone navi into the plugins directory. ```sh export ZSH_CUSTOM='/path/to/.zsh' -DST="$ZSH_CUSTOM/plugins" -mkdir -p "$DST" -cd "$DST" +plugins_dir="$ZSH_CUSTOM/plugins" +mkdir -p "$plugins_dir" +cd "$plugins_dir" git clone https://github.com/denisidoro/navi ``` From 022aee2b138748af988539378b8905b255bd53b1 Mon Sep 17 00:00:00 2001 From: Alexandre Beaulieu Date: Tue, 1 Oct 2019 18:23:51 -0400 Subject: [PATCH 5/5] fix: oh-my-zsh update no longer invokes `make install`. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 7a61600..38c9b35 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ Upgrading - brew: `brew update; brew reinstall navi` - git: `cd /opt/navi && sudo make update` -- oh-my-zsh: `cd "$(navi home)" && sudo make update` +- oh-my-zsh: `cd "$(navi home)" && git pull` Usage -----