What allows bash to autocomplete tmux "sub-commands"?

Unix & Linux Asked by StoneThrow on October 30, 2020

I’m trying to replicate some useful features from my work PC at home.

At work, bash will helpfully autocomplete tmux "sub-commands": e.g. I type "tmux new-s<tab>" and bash autocompletes that to "tmux new-session" (I hope "sub-command" is the right term). This doesn’t happen on my home PC — what can I do to set this up on my home PC?

I’ve looked around online and found some references to auto-complete within tmux, e.g. to auto-complete commands like move-window — but that’s not what I’m looking for.
I also found reference to a feature called "bash complete" — but on my work PC, I don’t find any reference to tmux in my ~/.bash_completion file or my /etc/bash_completion.d/ directory.

Can someone please explain either where/how else my work PC might have set up its tmux "sub-command" autocompletion (so that I can refer/learn from a working example), or how I can/should set this up?

Interesting side-note: both my work and home PCs autocomplete git "sub-commands"; e.g. typing "git clo<tab>" autocompletes to "git clone". I didn’t do anything specific to set that up — for both git and tmux, all I did as far as setup was "sudo apt install git" and "sudo apt install tmux", respectively.

One Answer

You can get your systems completion dir from pkg-config --variable=completionsdir bash-completion (/usr/share/bash-completion/completions/)

This is where dynamic completions are set up:

$ complete -p git
-bash: complete: git: no completion specification
$ git st<TAB>
st       stage    stash    status   sti
$ complete -p git
complete -o bashdefault -o default -o nospace -F __git_wrap__git_main git

If you want to set up tmux auto complete follow

Answered by laktak on October 30, 2020

Add your own answers!

Related Questions

SSH on port 443 with SSLH

1  Asked on December 21, 2021


Reformat date to unix time stamp in csv table

3  Asked on December 21, 2021


i3wm / debian accent marks

2  Asked on December 21, 2021 by danoiseman


View 1 monitor in VNC session?

1  Asked on December 21, 2021


Problem after installing snapd

1  Asked on December 21, 2021 by hr20dev


what’s the relationship between iptables and firwalld

1  Asked on December 21, 2021 by westfarmer


What is my shell environement?

1  Asked on December 21, 2021 by mikibelavista


How to reinstall python

1  Asked on December 19, 2021 by aditya-ultra


Nvidia driver; Unable to load info from any available system

1  Asked on December 19, 2021 by whitewind


No external network access on Beaglebone

0  Asked on December 19, 2021


Port forwarding with KVM

0  Asked on December 19, 2021 by ari-stehney


Copy/paste into SSH’d VIM from local (Windows) clipboard

10  Asked on December 17, 2021 by frickskit


How to get tab completion when using curly braces in Bash

5  Asked on December 17, 2021 by weston-ganger


libpam-pwquality not working in Ubuntu 16.04

1  Asked on December 17, 2021


Asus TUF Ubuntu 18.04.1 elantech mouse freezes frequently

1  Asked on December 17, 2021 by srajan-soni


Ask a Question

Get help from others!

© 2023 All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP