Skip to content

Commit

Permalink
Add support for --tmux-title option
Browse files Browse the repository at this point in the history
  • Loading branch information
afh committed Jan 2, 2025
1 parent c2e1861 commit a8a639b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/options.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ Usage: fzf [options]
--tmux[=OPTS] Start fzf in a tmux popup (requires tmux 3.3+)
[center|top|bottom|left|right][,SIZE[%]][,SIZE[%]]
(default: center,50%)
--tmux-title=STR Add given title to tmux popup (requires tmux 3.3+)
--layout=LAYOUT Choose layout: [default|reverse|reverse-list]
--border[=STYLE] Draw border around the finder
[rounded|sharp|bold|block|thinblock|double|horizontal|vertical|
Expand Down Expand Up @@ -457,6 +458,7 @@ type Options struct {
Output chan string
NoWinpty bool
Tmux *tmuxOptions
TmuxTitle string
ForceTtyIn bool
ProxyScript string
Bash bool
Expand Down Expand Up @@ -2674,6 +2676,8 @@ func parseOptions(index *int, opts *Options, allArgs []string) error {
if opts.Tmux, err = parseTmuxOptions(value, index); err != nil {
return err
}
} else if match, value := optString(arg, "--tmux-title="); match {
opts.TmuxTitle = value
} else if match, value := optString(arg, "--scheme="); match {
opts.Scheme = strings.ToLower(value)
} else if match, value := optString(arg, "-q", "--query="); match {
Expand Down
8 changes: 7 additions & 1 deletion src/tmux.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func runTmux(args []string, opts *Options) (int, error) {
// M Both The mouse position
// W Both The window position on the status line
// S -y The line above or below the status line
tmuxArgs := []string{"display-popup", "-E", "-B", "-d", dir}
tmuxArgs := []string{"display-popup", "-E", "-d", dir}
switch opts.Tmux.position {
case posUp:
tmuxArgs = append(tmuxArgs, "-xC", "-y0")
Expand All @@ -49,6 +49,12 @@ func runTmux(args []string, opts *Options) (int, error) {
tmuxArgs = append(tmuxArgs, "-w"+opts.Tmux.width.String())
tmuxArgs = append(tmuxArgs, "-h"+opts.Tmux.height.String())

if opts.TmuxTitle != "" {
tmuxArgs = append(tmuxArgs, "-T"+opts.TmuxTitle)
} else {
tmuxArgs = append(tmuxArgs, "-B")
}

return runProxy(argStr, func(temp string, needBash bool) (*exec.Cmd, error) {
sh, err := sh(needBash)
if err != nil {
Expand Down

0 comments on commit a8a639b

Please sign in to comment.