Skip to content

Commit

Permalink
Merge pull request #1151 from rsteube/tmux-choosebuffer
Browse files Browse the repository at this point in the history
tmux: choosebuffer
  • Loading branch information
rsteube authored May 19, 2022
2 parents a825490 + cc6792c commit b64af1b
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 24 deletions.
33 changes: 33 additions & 0 deletions completers/tmux_completer/cmd/chooseBuffer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package cmd

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

var chooseBufferCmd = &cobra.Command{
Use: "choose-buffer",
Short: "put a pane into buffer choice mode",
Run: func(cmd *cobra.Command, args []string) {},
}

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

chooseBufferCmd.Flags().StringS("F", "F", "", "specify format for each list item")
chooseBufferCmd.Flags().StringS("K", "K", "", "specify format for each shortcut key")
chooseBufferCmd.Flags().BoolS("N", "N", false, "start without the preview")
chooseBufferCmd.Flags().StringS("O", "O", "", "initial sort order")
chooseBufferCmd.Flags().BoolS("Z", "Z", false, "zoom the pane")
chooseBufferCmd.Flags().StringS("f", "f", "", "filter items")
chooseBufferCmd.Flags().BoolS("r", "r", false, "reverse sort order")
chooseBufferCmd.Flags().StringS("t", "t", "", "specify target window")
rootCmd.AddCommand(chooseBufferCmd)

// TODO formats
carapace.Gen(chooseBufferCmd).FlagCompletion(carapace.ActionMap{
"O": carapace.ActionValues("time", "name", "size"),
"t": tmux.ActionWindows(),
})
}
23 changes: 0 additions & 23 deletions completers/tmux_completer/cmd/chooseBuffer_generated.go

This file was deleted.

6 changes: 5 additions & 1 deletion pkg/actions/tools/git/change.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,11 @@ func ActionChanges(opts ChangeOpts) carapace.Action {
if len(line) > 3 {
if (opts.Staged && line[1] == ' ') ||
(opts.Unstaged && line[1] != ' ') {
if relativePath, err := filepath.Rel(c.Dir, root+"/"+line[3:]); err != nil {
path := line[3:]
if splitted := strings.SplitN(path, " -> ", 2); len(splitted) > 1 { // renamed
path = splitted[1]
}
if relativePath, err := filepath.Rel(c.Dir, root+"/"+path); err != nil {
return carapace.ActionMessage(err.Error())
} else {
untracked = append(untracked, relativePath, line[:2], style.ForPath(relativePath))
Expand Down

0 comments on commit b64af1b

Please sign in to comment.