Compare commits
No commits in common. "e3a78b077a98f036b7a5e3f4e79b92cbe6e6718b" and "02f617375433832d677426386eed9f9fe46aae3c" have entirely different histories.
e3a78b077a
...
02f6173754
@ -4,43 +4,15 @@
|
|||||||
set -o emacs
|
set -o emacs
|
||||||
bind '"\e": "\C-W\c-d"'
|
bind '"\e": "\C-W\c-d"'
|
||||||
|
|
||||||
OPEN_MODE="new_pane"
|
move_pane () {
|
||||||
|
|
||||||
while getopts ":l:v" option; do
|
|
||||||
case $option in
|
|
||||||
l)
|
|
||||||
OPEN_MODE="local"
|
|
||||||
;;
|
|
||||||
v)
|
|
||||||
VERBOSE=true
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
debug () {
|
|
||||||
if [ "$VERBOSE" = true ]; then
|
|
||||||
echo $1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
open_local () {
|
|
||||||
tmux send-keys "cd $PROJECT_PATH" Enter
|
|
||||||
|
|
||||||
# Close tmux popup if any
|
|
||||||
tmux display-popup -C
|
|
||||||
}
|
|
||||||
|
|
||||||
open_new_pane () {
|
|
||||||
tmux has-session -t $SESSION_NAME 2>/dev/null
|
tmux has-session -t $SESSION_NAME 2>/dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
debug "Session $SESSION_NAME missing, creating it."
|
|
||||||
tmux new-session -s $SESSION_NAME -d -n $PROJECT_NAME -c $PROJECT_PATH
|
tmux new-session -s $SESSION_NAME -d -n $PROJECT_NAME -c $PROJECT_PATH
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmux has-session -t $SESSION_NAME:$PROJECT_NAME 2>/dev/null
|
tmux has-session -t $SESSION_NAME:$PROJECT_NAME 2>/dev/null
|
||||||
if [ $? != 0 ]; then
|
if [ $? != 0 ]; then
|
||||||
debug "Window $PROJECT_NAME in $SESSION_NAME not found, creating it."
|
tmux new-window -t $SESSION_NAME: -n $PROJECT_NAME -d -c $PROJECT_PATH
|
||||||
tmux new-window -t $SESSION_NAME -n $PROJECT_NAME -d -c $PROJECT_PATH
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmux switch-client -t $SESSION_NAME:$PROJECT_NAME
|
tmux switch-client -t $SESSION_NAME:$PROJECT_NAME
|
||||||
@ -56,21 +28,21 @@ PROJECT_LIST=$(find ~/* -name .git -type d -prune 2>/dev/null)
|
|||||||
|
|
||||||
SELECTED=$(echo $PROJECT_LIST | sed 's/\/.git/\n/g' | sed "s/$(echo $HOME | sed 's/\//\\\//g')//" | cut -d'/' -f2- | fzf)
|
SELECTED=$(echo $PROJECT_LIST | sed 's/\/.git/\n/g' | sed "s/$(echo $HOME | sed 's/\//\\\//g')//" | cut -d'/' -f2- | fzf)
|
||||||
|
|
||||||
debug "Selected $SELECTED"
|
PROJECT_PATH=$(echo $PROJECT_LIST | sed 's/\/.git/\n/g' | grep $SELECTED)
|
||||||
|
|
||||||
PROJECT_PATH=$(echo $PROJECT_LIST | sed 's/\/.git/\n/g' | grep "${SELECTED}$")
|
|
||||||
PROJECT_ROOT=$(echo $SELECTED | cut -d '/' -f1)
|
PROJECT_ROOT=$(echo $SELECTED | cut -d '/' -f1)
|
||||||
PROJECT_NAME=$(echo $SELECTED | rev | cut -d '/' -f1 | rev)
|
PROJECT_NAME=$(echo $SELECTED | rev | cut -d '/' -f1 | rev)
|
||||||
|
|
||||||
SESSION_NAME=$([ -z "${CUSTOM_SESSIONS[$PROJECT_ROOT]}" ] && echo "$PROJECT_ROOT" || echo "${CUSTOM_SESSIONS[$PROJECT_ROOT]}")
|
SESSION_NAME=$([ -z "${CUSTOM_SESSIONS[$PROJECT_ROOT]}" ] && echo "$PROJECT_ROOT" || echo "${CUSTOM_SESSIONS[$PROJECT_ROOT]}")
|
||||||
|
|
||||||
debug "Project path is $PROJECT_PATH"
|
while getopts ":l" option; do
|
||||||
|
case $option in
|
||||||
|
l)
|
||||||
|
tmux send-keys "cd $PROJECT_PATH" Enter
|
||||||
|
|
||||||
case $OPEN_MODE in
|
# Close tmux popup if any
|
||||||
"new_pane")
|
tmux display-popup -C
|
||||||
open_new_pane
|
|
||||||
;;
|
;;
|
||||||
"local")
|
esac
|
||||||
open_local
|
done
|
||||||
;;
|
|
||||||
esac
|
if [ $OPTIND -eq 1 ]; then move_pane "$SELECTED"; fi
|
||||||
|
Loading…
Reference in New Issue
Block a user