Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for --tmux-title option #4155

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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