feat(tmux): Add local project opener shortcut
This commit is contained in:
parent
62d0c1d8a1
commit
64dd619da8
@ -4,15 +4,7 @@
|
||||
set -o emacs
|
||||
bind '"\e": "\C-W\c-d"'
|
||||
|
||||
declare -A CUSTOM_SESSIONS
|
||||
CUSTOM_SESSIONS[Projects]=Halia
|
||||
|
||||
SELECTED=$(find . -name .git -type d -prune -not -path "./.*" 2>/dev/null | sed 's/\/.git//' | cut -d'/' -f2- | fzf)
|
||||
|
||||
ROOT=$(echo $SELECTED | cut -d '/' -f1)
|
||||
PROJECT=$(echo $SELECTED | rev | cut -d '/' -f1 | rev)
|
||||
SESSION_NAME=$([ -z "${CUSTOM_SESSIONS[$ROOT]}" ] && echo "$ROOT" || echo "${CUSTOM_SESSIONS[$ROOT]}")
|
||||
|
||||
move_pane () {
|
||||
tmux has-session -t $SESSION_NAME 2>/dev/null
|
||||
if [ $? != 0 ]; then
|
||||
tmux new-session -s $SESSION_NAME -d -n $PROJECT #2>/dev/null
|
||||
@ -27,3 +19,29 @@ tmux switch-client -t $SESSION_NAME:$PROJECT
|
||||
|
||||
# Close tmux popup if any
|
||||
tmux display-popup -C
|
||||
}
|
||||
|
||||
declare -A CUSTOM_SESSIONS
|
||||
CUSTOM_SESSIONS[Projects]=Halia
|
||||
|
||||
SELECTED=$(find . -name .git -type d -prune -not -path "./.*" 2>/dev/null | sed 's/\/.git//' | cut -d'/' -f2- | fzf)
|
||||
|
||||
ROOT=$(echo $SELECTED | cut -d '/' -f1)
|
||||
PROJECT=$(echo $SELECTED | rev | cut -d '/' -f1 | rev)
|
||||
SESSION_NAME=$([ -z "${CUSTOM_SESSIONS[$ROOT]}" ] && echo "$ROOT" || echo "${CUSTOM_SESSIONS[$ROOT]}")
|
||||
|
||||
while getopts ":l" option; do
|
||||
case $option in
|
||||
l)
|
||||
tmux send-keys 'cd $SELECTED' Enter
|
||||
|
||||
# Close tmux popup if any
|
||||
tmux display-popup -C
|
||||
;;
|
||||
*)
|
||||
move_pane
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
||||
|
@ -79,6 +79,7 @@ bind-key S command-prompt -p "Name of new session: " "new-session -s '%%'"
|
||||
|
||||
unbind o
|
||||
bind-key o display-popup "tmux-projectinator"
|
||||
bind-key O display-popup "tmux-projectinator -l"
|
||||
|
||||
# Quick pane resizing using arrow keys
|
||||
bind-key -r H resize-pane -L 5
|
||||
|
Loading…
Reference in New Issue
Block a user