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

Recent update breaks autocomplete for tmux plugin aliases #12282

Open
matthew-nm opened this issue Mar 13, 2024 · 2 comments · May be fixed by #12278
Open

Recent update breaks autocomplete for tmux plugin aliases #12282

matthew-nm opened this issue Mar 13, 2024 · 2 comments · May be fixed by #12278

Comments

@matthew-nm
Copy link

matthew-nm commented Mar 13, 2024

Describe the bug

The latest _build_tmux_alias causes the tmux ta alias to be defined as the following function,

ta () {
  if [[ -z $1 ]] || [[ ${1:0:1} == '-' ]]
  then
    tmux attach "$@"
  else
    tmux attach -t "$@"
  fi
}

instead of the previous command,

ta: aliased to tmux attach -t

which makes autocompletion of session names not work. When using TAB to autocomplete, instead of providing the list of sessions to choose, it provides the list of files/folders in the current directory, presumably because it doesn't know what command it's trying to autocomplete for.

Steps to reproduce

  1. run omz update
  2. try to use ta TAB autocompletion as before

Expected behavior

Ideally, pressing TAB after entering ta would provide a list of current sessions, as before.

Screenshots and recordings

No response

OS / Linux distribution

macOS

Zsh version

5.9

Terminal emulator

iTerm2

If using WSL on Windows, which version of WSL

None

Additional context

No response

@detroyejr detroyejr linked a pull request Mar 26, 2024 that will close this issue
8 tasks
@detroyejr
Copy link
Contributor

@matthew-nm I've issued a PR to fix this and am just waiting for it to be reviewed and merged. Feel free to test and report if this doesn't give you everything you had before.

@matthew-nm
Copy link
Author

@detroyejr Excellent! I've tested and it works great.

The results are shown slightly differently between the alias and the full command, but I don't think it would bother anyone.

❯ tmux attach -t
 -- detached session --
flutter_3_0_course  -- 2 windows (created Tue Feb 20 20:40:50 2024)
 -- attached session --
dotfiles            -- 3 windows (created Wed Jan 17 16:03:51 2024) (attached)
flutter_randomizer  -- 2 windows (created Mon Mar 18 21:10:47 2024) (attached)

❯ ta
 -- tmux session --
dotfiles            --  3 windows (created Wed Jan 17 16:03:51 2024) (attached)
flutter_3_0_course  --  2 windows (created Tue Feb 20 20:40:50 2024)
flutter_randomizer  --  2 windows (created Mon Mar 18 21:10:47 2024) (attached)

For my own curiosity, why is something like the following not used?

function _build_tmux_alias {
  eval "if [[ -z \$1 ]] || [[ \${1:0:1} == '-' ]]; then
    alias \$1=\"tmux $2\"
  else
    alias \$1=\"tmux $2 $3\"
  fi"
}

I did a quick test just now and it seems to work OK without having to reimplement any of the completions. And I imagine it would stand up to any completion updates in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog
Development

Successfully merging a pull request may close this issue.

2 participants