diff --git a/Examples.md b/Examples.md index b03dc39..14c8f63 100644 --- a/Examples.md +++ b/Examples.md @@ -450,6 +450,20 @@ ftags() { ### tmux +```sh +# tm - create new tmux session, or switch to existing one. Works from within tmux too. (@bag-man) +# `tm` will allow you to select your tmux session via fzf. +# `tm irc` will attach to the irc session (if it exists), else it will create it. + +tm() { + [[ -n "$TMUX" ]] && change="switch-client" || change="attach-session" + if [ $1 ]; then + tmux $change -t "$1" 2>/dev/null || (tmux new-session -d -s $1 && tmux $change -t "$1"); return + fi + session=$(tmux list-sessions -F "#{session_name}" 2>/dev/null | fzf --exit-0) && tmux $change -t "$session" || echo "No sessions found." +} +``` + ```sh # fs [FUZZY PATTERN] - Select selected tmux session # - Bypass fuzzy finder if there's only one match (--select-1)