diff --git a/README.md b/README.md index 38c9b352..be2c3c75 100644 --- a/README.md +++ b/README.md @@ -120,14 +120,18 @@ You can use **navi** as a widget to your shell: This way, your history is correctly populated and you can edit the command as you wish before executing it. -Right now, there's only a widget for zsh. If you want for other shells, please upvote [this issue](https://github.com/denisidoro/navi/issues/37). - -In order to use it, add this line to your `.zshrc`-like file: +In order to use it, add this line to your `.bashrc`-like file: ```sh +# bash +source "$(navi widget bash)" + +# zsh source "$(navi widget zsh)" ``` -Then, simply hit `Alt+G`. +By default, `Ctrl+G` is assigned to launching **navi**. If you want to change the keybinding, replace the argument of `bind` or `bindkey` in [the widget file](https://github.com/denisidoro/navi/search?q=filename%3Anavi.plugin.*&unscoped_q=filename%3Anavi.plugin.*). + +If you want a widget for other shells, please upvote [this issue](https://github.com/denisidoro/navi/issues/37). ### More options diff --git a/navi b/navi index 46a70656..688ea952 100755 --- a/navi +++ b/navi @@ -35,7 +35,7 @@ source "${SCRIPT_DIR}/src/main.sh" ##? full docs ##? Please refer to the README at https://github.com/denisidoro/navi -VERSION="0.10.3" +VERSION="0.11.0" NAVI_ENV="${NAVI_ENV:-prod}" opts::eval "$@" diff --git a/navi.plugin.bash b/navi.plugin.bash new file mode 100644 index 00000000..64e3d4dd --- /dev/null +++ b/navi.plugin.bash @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +bind '"\C-g": " \C-u \C-a\C-k`printf \"\\e\" && navi --print`\e\C-e\C-y\C-a\C-d\C-y\ey\C-h\C-e\C-b"' diff --git a/navi.plugin.zsh b/navi.plugin.zsh index be75f179..60c2ea46 100644 --- a/navi.plugin.zsh +++ b/navi.plugin.zsh @@ -1,13 +1,12 @@ -local _navi_path=$(dirname $0:A) +_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)" + 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 +bindkey '^g' _call_navi diff --git a/src/main.sh b/src/main.sh index b95a7861..7e9771a2 100644 --- a/src/main.sh +++ b/src/main.sh @@ -98,6 +98,7 @@ handler::widget() { case "$SH" in zsh) widget="${SCRIPT_DIR}/navi.plugin.zsh" ;; + bash) widget="${SCRIPT_DIR}/navi.plugin.bash" ;; *) echoerr "Invalid shell: $SH"; exit 1 ;; esac