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
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
|
|
@ -55,4 +55,6 @@ autocmd FileType gitcommit setlocal spell
|
|||
" Display extra whitespace
|
||||
set list listchars=tab:»·,trail:·
|
||||
|
||||
nnoremap <silent> <C-f> :silent !tmux neww tmux-sessioniser<CR>
|
||||
|
||||
lua require("opdavies")
|
||||
|
|
|
@ -33,5 +33,7 @@ _load_settings() {
|
|||
|
||||
_load_settings "$HOME/.zsh/configs"
|
||||
|
||||
bindkey -s "^f" "tmux-sessioniser\n"
|
||||
|
||||
# Local config
|
||||
[[ -f ~/.zshrc.local ]] && source ~/.zshrc.local
|
||||
|
|
Loading…
Reference in a new issue