Skip to content

Commit e6edb38

Browse files
authored
Merge pull request #3003 from carapace-sh/zsh-abs-alias
zsh: support alias with absolute path
2 parents 3543445 + dac318b commit e6edb38

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

cmd/carapace/cmd/invoke.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"github.com/carapace-sh/carapace-bridge/pkg/actions/bridge"
1616
"github.com/carapace-sh/carapace-bridge/pkg/bridges"
1717
"github.com/carapace-sh/carapace/pkg/uid"
18+
"github.com/carapace-sh/carapace/third_party/golang.org/x/sys/execabs"
1819
"github.com/spf13/cobra"
1920
)
2021

@@ -29,6 +30,13 @@ var invokeCmd = &cobra.Command{
2930
Short: "",
3031
Args: cobra.MinimumNArgs(1),
3132
Run: func(cmd *cobra.Command, args []string) {
33+
if completer := args[0]; strings.Contains(completer, "/") {
34+
// patch to base if resolves to path executable (#2971)
35+
base := filepath.Base(completer)
36+
if abs, err := execabs.LookPath(base); err == nil && args[0] == abs {
37+
args[0] = base
38+
}
39+
}
3240
// TODO newInvoke(cmd, args)
3341
oldInvoke(cmd, args)
3442
},

0 commit comments

Comments
 (0)