fix ctrl r bindings in zsh, polishing

pull/77/head v2.5.2
Simon Let 6 years ago
parent 5293c21ee8
commit b8be59c154
  1. 2
      Makefile
  2. 12
      cmd/config/main.go
  3. 3
      cmd/control/cmd/status.go
  4. 1
      conf/config-dev.toml
  5. 1
      conf/config.toml
  6. 37
      scripts/reshctl.sh
  7. 1
      scripts/shellrc.sh
  8. 4
      scripts/widgets.sh

@ -11,7 +11,7 @@ build: submodules bin/resh-session-init bin/resh-collect bin/resh-postcollect bi
install: build conf/config-dev.toml install: build conf/config-dev.toml
scripts/install.sh scripts/install.sh
# Dev config # Dev config
cp -f conf/config-dev.toml ~/.config/ cp -f conf/config-dev.toml ~/.config/resh.toml
test_go: test_go:
# Running tests # Running tests

@ -6,6 +6,7 @@ import (
"os" "os"
"os/user" "os/user"
"path/filepath" "path/filepath"
"strings"
"github.com/BurntSushi/toml" "github.com/BurntSushi/toml"
"github.com/curusarn/resh/pkg/cfg" "github.com/curusarn/resh/pkg/cfg"
@ -31,15 +32,14 @@ func main() {
os.Exit(1) os.Exit(1)
} }
*configKey = strings.ToLower(*configKey)
switch *configKey { switch *configKey {
case "BindArrowKeysBash": case "bindarrowkeysbash":
fallthrough
case "bindArrowKeysBash":
printBoolNormalized(config.BindArrowKeysBash) printBoolNormalized(config.BindArrowKeysBash)
case "BindArrowKeysZsh": case "bindarrowkeyszsh":
fallthrough
case "bindArrowKeysZsh":
printBoolNormalized(config.BindArrowKeysZsh) printBoolNormalized(config.BindArrowKeysZsh)
case "bindcontrolr":
printBoolNormalized(config.BindControlR)
default: default:
fmt.Println("Error: illegal --key!") fmt.Println("Error: illegal --key!")
os.Exit(1) os.Exit(1)

@ -44,7 +44,7 @@ var statusCmd = &cobra.Command{
} }
fmt.Println() fmt.Println()
fmt.Println("Arrow key bindnigs ...") fmt.Println("Arrow key bindings ...")
if config.BindArrowKeysBash { if config.BindArrowKeysBash {
fmt.Println(" * bash future sessions: ENABLED (not recommended)") fmt.Println(" * bash future sessions: ENABLED (not recommended)")
} else { } else {
@ -55,6 +55,7 @@ var statusCmd = &cobra.Command{
} else { } else {
fmt.Println(" * zsh future sessions: DISABLED (not recommended)") fmt.Println(" * zsh future sessions: DISABLED (not recommended)")
} }
exitCode = status.ReshStatus exitCode = status.ReshStatus
}, },
} }

@ -4,3 +4,4 @@ sesshistInitHistorySize = 1000
debug = true debug = true
bindArrowKeysBash = false bindArrowKeysBash = false
bindArrowKeysZsh = true bindArrowKeysZsh = true
bindControlR = true

@ -4,3 +4,4 @@ sesshistInitHistorySize = 1000
debug = true debug = true
bindArrowKeysBash = false bindArrowKeysBash = false
bindArrowKeysZsh = true bindArrowKeysZsh = true
bindControlR = false

@ -97,17 +97,20 @@ __resh_unbind_all() {
__resh_unbind_control_R __resh_unbind_control_R
} }
# wrapper for resh-cli # wrapper for resh-cli for calling resh directly
# meant to be launched on ctrl+R
resh() { resh() {
# TODO: rewrite this based on the widget local buffer
if resh-cli --sessionID "$__RESH_SESSION_ID" --pwd "$PWD" > ~/.resh/cli_last_run_out.txt 2>&1; then buffer=$(resh-cli --sessionID "$__RESH_SESSION_ID" --pwd "$PWD")
# insert on cmdline status_code=$?
cat ~/.resh/cli_last_run_out.txt if [ $status_code = 111 ]; then
eval "$(cat ~/.resh/cli_last_run_out.txt)" # execute
# TODO: get rid of eval echo "$buffer"
eval "$buffer"
elif [ $status_code = 0 ]; then
# paste
echo "$buffer"
else else
# print errors echo "$buffer" > ~/.resh/cli_last_run_out.txt
echo "resh-cli ERROR:" echo "resh-cli ERROR:"
cat ~/.resh/cli_last_run_out.txt cat ~/.resh/cli_last_run_out.txt
fi fi
@ -176,9 +179,21 @@ reshctl() {
202) 202)
# show status # show status
if [ "${__RESH_arrow_keys_bind_enabled-0}" != 0 ]; then if [ "${__RESH_arrow_keys_bind_enabled-0}" != 0 ]; then
echo " * this session: ENABLED" echo ' * this session: ENABLED'
else
echo ' * this session: DISABLED'
fi
echo
echo 'Control R binding ...'
if [ "$(resh-config --key BindControlR)" = true ]; then
echo ' * future sessions: ENABLED (experimental)'
else
echo ' * future sessions: DISABLED (recommended)'
fi
if [ "${__RESH_control_R_bind_enabled-0}" != 0 ]; then
echo ' * this session: ENABLED'
else else
echo " * this session: DISABLED" echo ' * this session: DISABLED'
fi fi
return 0 return 0
;; ;;

@ -96,6 +96,7 @@ if [ -z "${__RESH_INIT_DONE+x}" ]; then
echo "RESH error: unknown shell (init)" echo "RESH error: unknown shell (init)"
echo "$__RESH_SHELL" echo "$__RESH_SHELL"
fi fi
[ "$(resh-config --key BindControlR)" = true ] && reshctl enable ctrl_r_binding
__RESH_INIT_DONE=1 __RESH_INIT_DONE=1
fi fi

@ -102,14 +102,14 @@ __resh_widget_control_R() {
# zsh # zsh
zle accept-line zle accept-line
elif [ -n "${BASH_VERSION-}" ]; then elif [ -n "${BASH_VERSION-}" ]; then
echo "BASH is not currently not supported" echo "BASH is not currently not supported for control R binding - sorry"
# bash # bash
# TODO set chained keyseq to accept-line # TODO set chained keyseq to accept-line
true true
fi fi
elif [ $status_code = 0 ]; then elif [ $status_code = 0 ]; then
if [ -n "${BASH_VERSION-}" ]; then if [ -n "${BASH_VERSION-}" ]; then
echo "BASH is not currently not supported" echo "BASH is not currently not supported for control R binding - sorry"
# bash # bash
# TODO set chained keyseq to nothing # TODO set chained keyseq to nothing
true true

Loading…
Cancel
Save