Skip to content

Commit

Permalink
tmux: bind-key
Browse files Browse the repository at this point in the history
  • Loading branch information
rsteube committed May 19, 2022
1 parent 9f1d894 commit 10a70a3
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 27 deletions.
3 changes: 2 additions & 1 deletion completers/tmux_completer/cmd/_tmux
Original file line number Diff line number Diff line change
Expand Up @@ -1896,4 +1896,5 @@ for f in ${(M)${(k)functions}:#_tmux-*} ; do
[[ -n ${rev[${f#_tmux-}]} ]] && _tmux_aliases+=( "${rev[${f#_tmux-}]}${desc:+:$desc}" )
done

_tmux "$@"
compquote '' 2>/dev/null && _tmux "$@"
compdef _tmux tmux
36 changes: 36 additions & 0 deletions completers/tmux_completer/cmd/bindKey.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package cmd

import (
"github.com/rsteube/carapace"
"github.com/rsteube/carapace-bin/pkg/actions/bridge"
"github.com/spf13/cobra"
)

var bindKeyCmd = &cobra.Command{
Use: "bind-key",
Short: "bind a key to a command",
Run: func(cmd *cobra.Command, args []string) {},
}

func init() {
carapace.Gen(bindKeyCmd).Standalone()

bindKeyCmd.Flags().StringS("N", "N", "", "attach a note to the key")
bindKeyCmd.Flags().StringS("T", "T", "", "specify key table for the binding")
bindKeyCmd.Flags().BoolS("n", "n", false, "make the binding work without the need for the prefix key")
bindKeyCmd.Flags().BoolS("r", "r", false, "the key may repeat")
rootCmd.AddCommand(bindKeyCmd)

// TODO key table

carapace.Gen(bindKeyCmd).PositionalCompletion(
carapace.ActionValues(),
)

carapace.Gen(bindKeyCmd).PositionalAnyCompletion(
carapace.ActionCallback(func(c carapace.Context) carapace.Action {
c.Args = c.Args[1:]
return bridge.ActionCarapaceBin("tmux").Invoke(c).ToA()
}),
)
}
22 changes: 0 additions & 22 deletions completers/tmux_completer/cmd/bindKey_generated.go

This file was deleted.

4 changes: 0 additions & 4 deletions completers/tmux_completer/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,4 @@ func init() {
"c": carapace.ActionFiles(),
"f": carapace.ActionFiles(),
})

carapace.Gen(rootCmd).PositionalCompletion(
carapace.ActionFiles(),
)
}

0 comments on commit 10a70a3

Please sign in to comment.