feat: add tmux-sessioner script
Add a script for quickly navigating between directories using fzf and tmux sessions. Executable within zsh and Vim.
This commit is contained in:
parent
2f2c020719
commit
73e76b4d97
3 changed files with 33 additions and 0 deletions
29
bin/bin/tmux-sessioniser
Executable file
29
bin/bin/tmux-sessioniser
Executable file
|
@ -0,0 +1,29 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Quickly navigate between different directories using fzf and tmux sessions
|
||||
# (Thanks, ThePrimeagen!).
|
||||
#
|
||||
# https://github.com/ThePrimeagen/.dotfiles/blob/master/bin/.local/bin/tmux-sessionizer
|
||||
# https://frontendmasters.com/workshops/dev-productivity
|
||||
|
||||
if [[ $# -eq 1 ]]; then
|
||||
selected=$1
|
||||
else
|
||||
# Get the session name from fuzzy-finding list of directories and generating a
|
||||
# tmux-safe version.
|
||||
selected=$(find ~/ ~/Code ~/Code/clients ~/Code/os ~/Code/Personal ~/Documents/Talks/ -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
fi
|
||||
|
||||
selected_name=$(basename "$selected" | tr . -)
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Create a new session if tmux does not already have a session matching the
|
||||
# selected session name.
|
||||
if ! tmux has-session -t $selected_name 2> /dev/null; then
|
||||
tmux new-session -s $selected_name -c $selected -d
|
||||
fi
|
||||
|
||||
tmux switch-client -t $selected_name
|
Loading…
Add table
Add a link
Reference in a new issue