refactor: combine bin directories
This commit is contained in:
parent
f3f1051f1f
commit
459428a979
16 changed files with 0 additions and 38 deletions
39
bin/tmux-sessioniser
Executable file
39
bin/tmux-sessioniser
Executable file
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env 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/Books ~/Documents/Talks/ -mindepth 1 -maxdepth 1 -type d -not -name ".*" | sort | fzf)
|
||||
fi
|
||||
|
||||
if [[ -z $selected ]]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
is_tmux_running=$(pgrep tmux)
|
||||
selected_name=$(basename "$selected" | tr . -)
|
||||
|
||||
if [[ -z $TMUX ]] && [[ -z $is_tmux_running ]]; then
|
||||
tmux new-session -s $selected_name -c $selected
|
||||
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
|
||||
|
||||
if [[ -z $TMUX ]]; then
|
||||
tmux attach-session -t $selected_name
|
||||
else
|
||||
tmux switch-client -t $selected_name
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue