Skip to content

Commit

Permalink
feat(tmux): add sessionizer
Browse files Browse the repository at this point in the history
  • Loading branch information
KirkEasterson committed Oct 4, 2024
1 parent 9cf25c5 commit a73a436
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
29 changes: 29 additions & 0 deletions bin/.local/bin/tmux_sessionizer.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/sh

# based on:
# - https://github.com/ThePrimeagen/.dotfiles/blob/602019e902634188ab06ea31251c01c1a43d1621/bin/.local/scripts/tmux-sessionizer

if [ $# -eq 1 ]; then
selected=$1
else
selected=$(find ~/dev -mindepth 1 -maxdepth 2 -type d | fzf)
fi

if [ -z "$selected" ]; then
exit 0
fi

selected_name=$(basename "$selected" | tr . _)

if [ -n "$TMUX" ]; then
tmux switch-client -t "$selected_name"
fi

tmux_running=$(pgrep tmux)

if [ -z "$tmux_running" ] || ! tmux has-session -t="$selected_name" 2>/dev/null; then
tmux new-session -d -s "$selected_name" -c "$selected"
fi

# TODO: make this work
tmux attach-session -t "$selected_name"
6 changes: 6 additions & 0 deletions zsh/.config/zsh/.zshrc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ _fix_cursor() {

precmd_functions+=(_fix_cursor)

# tmux sessionizer
tmux_sessionizer() tmux_sessionizer.sh
zle -N tmux_sessionizer
bindkey -M viins '^F' tmux_sessionizer
bindkey -M vicmd '^F' tmux_sessionizer

# like my nvim mapping
bindkey -M viins '^Y' autosuggest-accept

Expand Down

0 comments on commit a73a436

Please sign in to comment.