diff --git a/.config/bash/.bashrc b/.config/bash/.bashrc index d12c4d0..e0770e5 100644 --- a/.config/bash/.bashrc +++ b/.config/bash/.bashrc @@ -32,7 +32,7 @@ export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quo # Add some custom keybinds bind '"\C-o":"lfcd\n"' -bind '"\C-t":"tms\n"' +bind '"\C-g":"tms\n"' bind '"\C-w":"tms $(pwd)\n"' bind '"\C-n":"zk edit --interactive --sort modified-\n"' bind '"\C-f":"cd $(dirname "$(fzf)")\n"' diff --git a/.local/bin/tmux-sessioniser b/.local/bin/tmux-sessioniser index c7cc6d6..d5156ee 100755 --- a/.local/bin/tmux-sessioniser +++ b/.local/bin/tmux-sessioniser @@ -4,25 +4,32 @@ # connect to an existing one. if [[ $# -eq 1 ]]; then + echo $1 selected=$1 else - selected=$(find ~/repos/github.com/*/ ~/repos/gitlab.com/inkletblot ~/.config ~/ ~/nextcloud ~/nextcloud/*/ -mindepth 1 -maxdepth 1 -type d | fzf) + selected=$(find ~/repos/github.com/*/ ~/repos/gitlab.inkletblot.com/inkletblot ~/.config ~/ ~/nextcloud ~/nextcloud/*/ -mindepth 1 -maxdepth 1 -type d | fzf) fi if [[ -z $selected ]]; then exit 0 fi -selected_name=$(basename "$selected" | tr . _) -tmux_running=$(pgrep tmux) +selected_name=$(basename "$selected" | tr ":,. " _) -if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then - tmux new-session -s "$selected_name" -c "$selected" +switch_to() { + if [[ -z $TMUX ]]; then + tmux attach-session -t "$selected_name" + else + tmux switch-client -t "$selected_name" + fi +} + +if tmux has-session -t="$selected_name" 2>/dev/null; then + switch_to exit 0 fi -if ! tmux has-session -t="$selected_name" 2>/dev/null; then - tmux new-session -ds "$selected_name" -c "$selected" -fi +tmux new-session -ds "$selected_name" -c "$selected" +switch_to -tmux switch-client -t "$selected_name" +tmux send-keys -t "$selected_name" "ready-tmux"