Last active
December 11, 2023 17:12
-
-
Save mmm/f09e6e4e9a10105372369c86d02df8a9 to your computer and use it in GitHub Desktop.
tmux fuzzy launcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
__tmux_find_session_like() { | |
local requested_session=$1 | |
tmux list-sessions | sed -E 's/:.*$//' | fzf --filter=$requested_session --no-sort | |
} | |
__tmux_create_or_attach_to() { | |
local requested_session=$1 | |
local session_name=$(__tmux_find_session_like $requested_session) | |
[ -n "$session_name" ] \ | |
&& tmux attach-session -t $session_name \ | |
|| tmux new-session -s $requested_session | |
} | |
t() { | |
local session=$1 | |
[ -n "$session" ] \ | |
&& __tmux_create_or_attach_to $session \ | |
|| tmux ls | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
source the above from your
.bashrc
or shell startup.Usage:
t
: lists existing tmux sessionst <blah>
: attach to session whose names uniquely matches with the<blah>
text fragment (create a new session of this name if you can't match)