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
scripts/install.sh
# Dev config
cp -f conf/config-dev.toml ~/.config/
cp -f conf/config-dev.toml ~/.config/resh.toml
test_go:
# Running tests

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

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

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

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

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

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

@ -102,14 +102,14 @@ __resh_widget_control_R() {
# zsh
zle accept-line
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
# TODO set chained keyseq to accept-line
true
fi
elif [ $status_code = 0 ]; 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
# TODO set chained keyseq to nothing
true

Loading…
Cancel
Save