fix issues with zsh and completions

pull/30/head
Simon Let 6 years ago
parent 4c7c1972e8
commit ff8f182b75
  1. 13
      Makefile
  2. 10
      cmd/control/cmd/completion.go
  3. 6
      cmd/control/cmd/debug.go
  4. 3
      cmd/control/cmd/root.go
  5. 15
      scripts/util.sh

@ -82,15 +82,20 @@ install: build submodules/bash-preexec/bash-preexec.sh scripts/shellrc.sh conf/c
[ ! -f ~/.resh/history.json ] || mv ~/.resh/history.json ~/.resh_history.json [ ! -f ~/.resh/history.json ] || mv ~/.resh/history.json ~/.resh_history.json
# Adding resh shellrc to .bashrc ... # Adding resh shellrc to .bashrc ...
grep '[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' ~/.bashrc ||\ grep '[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' ~/.bashrc ||\
echo '[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' >> ~/.bashrc echo -e '\n[[ -f ~/.resh/shellrc ]] && source ~/.resh/shellrc' >> ~/.bashrc
# Adding bash-preexec to .bashrc ... # Adding bash-preexec to .bashrc ...
grep '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' ~/.bashrc ||\ grep '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' ~/.bashrc ||\
echo '[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc echo -e '\n[[ -f ~/.bash-preexec.sh ]] && source ~/.bash-preexec.sh' >> ~/.bashrc
# Adding resh shellrc to .zshrc ... # Adding resh shellrc to .zshrc ...
grep '[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' ~/.zshrc ||\ grep '[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' ~/.zshrc ||\
echo '[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' >> ~/.zshrc echo -e '\n[ -f ~/.resh/shellrc ] && source ~/.resh/shellrc' >> ~/.zshrc
@# Deleting zsh completion cache - for future use
@# [ ! -e ~/.zcompdump ] || rm ~/.zcompdump
# Restarting resh daemon ... # Restarting resh daemon ...
-[ ! -f ~/.resh/resh.pid ] || kill -SIGTERM $$(cat ~/.resh/resh.pid) -if [ ! -f ~/.resh/resh.pid ]; then\
kill -SIGTERM $$(cat ~/.resh/resh.pid);\
rm ~/.resh/resh.pid;\
fi
nohup resh-daemon &>/dev/null & disown nohup resh-daemon &>/dev/null & disown
# Reloading rc files # Reloading rc files
. ~/.resh/shellrc . ~/.resh/shellrc

@ -10,20 +10,20 @@ import (
// completionCmd represents the completion command // completionCmd represents the completion command
var completionCmd = &cobra.Command{ var completionCmd = &cobra.Command{
Use: "completion", Use: "completion",
Short: "Generates bash/zsh completion scripts", Short: "generate bash/zsh completion scripts",
Long: `To load completion run Long: `To load completion run
. <(reshctl completion bash) . <(reshctl completion bash)
OR OR
. <(reshctl completion zsh) . <(reshctl completion zsh) && compdef _reshctl reshctl
`, `,
} }
var completionBashCmd = &cobra.Command{ var completionBashCmd = &cobra.Command{
Use: "bash", Use: "bash",
Short: "Generates bash completion scripts", Short: "generate bash completion scripts",
Long: `To load completion run Long: `To load completion run
. <(reshctl completion bash) . <(reshctl completion bash)
@ -36,10 +36,10 @@ var completionBashCmd = &cobra.Command{
var completionZshCmd = &cobra.Command{ var completionZshCmd = &cobra.Command{
Use: "zsh", Use: "zsh",
Short: "Generates zsh completion scripts", Short: "generate zsh completion scripts",
Long: `To load completion run Long: `To load completion run
. <(reshctl completion zsh) . <(reshctl completion zsh) && compdef _reshctl reshctl
`, `,
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
rootCmd.GenZshCompletion(os.Stdout) rootCmd.GenZshCompletion(os.Stdout)

@ -12,13 +12,13 @@ import (
var debugCmd = &cobra.Command{ var debugCmd = &cobra.Command{
Use: "debug", Use: "debug",
Short: "Debug utils for resh", Short: "debug utils for resh",
Long: "Reloads resh rc files. Shows logs and output from last runs of resh", Long: "Reloads resh rc files. Shows logs and output from last runs of resh",
} }
var debugReloadCmd = &cobra.Command{ var debugReloadCmd = &cobra.Command{
Use: "reload", Use: "reload",
Short: "Reload resh rc files", Short: "reload resh rc files",
Long: "Reload resh rc files", Long: "Reload resh rc files",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
exitCode = status.ReloadRcFiles exitCode = status.ReloadRcFiles
@ -27,7 +27,7 @@ var debugReloadCmd = &cobra.Command{
var debugOutputCmd = &cobra.Command{ var debugOutputCmd = &cobra.Command{
Use: "output", Use: "output",
Short: "Shows output from last runs of resh", Short: "shows output from last runs of resh",
Long: "Shows output from last runs of resh", Long: "Shows output from last runs of resh",
Run: func(cmd *cobra.Command, args []string) { Run: func(cmd *cobra.Command, args []string) {
files := []string{ files := []string{

@ -11,8 +11,7 @@ var exitCode status.Code
var rootCmd = &cobra.Command{ var rootCmd = &cobra.Command{
Use: "reshctl", Use: "reshctl",
Short: "Reshctl (RESH control) - enables you to enable/disable features and more.", Short: "Reshctl (RESH control) - enable/disable RESH features and more.",
Long: `Enables you to enable/disable RESH bindings for arrows and C-R.`,
} }
// Execute reshctl // Execute reshctl

@ -63,8 +63,19 @@ __resh_bash_completion_init() {
} }
__resh_zsh_completion_init() { __resh_zsh_completion_init() {
# shellcheck disable=SC2206 # NOTE: this is hacky - each completion needs to be added individually
fpath=(~/.resh/zsh_completion.d $fpath) # TODO: fix later
# fpath=(~/.resh/zsh_completion.d $fpath)
# we should be using fpath but that doesn't work well with oh-my-zsh
# so we are just adding it manually
# shellcheck disable=1090
source ~/.resh/zsh_completion.d/_reshctl && compdef _reshctl reshctl
# TODO: test and use this
# NOTE: this is not how globbing works
# for f in ~/.resh/zsh_completion.d/_*; do
# source ~/.resh/zsh_completion.d/_$f && compdef _$f $f
# done
} }
__resh_session_init() { __resh_session_init() {

Loading…
Cancel
Save