I created a simple function in .bashrc to ssh into a specific machine and enter a specific tmux session:
# Function to ssh to a machine with tmux
connect() {
local host=$1
local session=${2:-main}
# Check if tmux session exists
if ssh -q "$host" "tmux has-session -t $session 2>/dev/null"; then
ssh -t "$host" "tmux attach -t $session"
else
# Create tmux session if it doesn't exist
ssh -t "$host" "tmux new-session -s $session"
fi
}
Everything works so well, but previously when I typed ssh and pressed TAB I got autocomplete for the existing machines that I have defined in the .ssh/config file, and am looking for a way to enable that autocomplete for the new connect alias.
In my case this did the trick:
Enabling autocomplete of another command for example
cdwill be like this