Add system-type filters, add git-clone handling to main script
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
#!/bin/zsh
|
||||
|
||||
switch_to() {
|
||||
tmux_switch_to() {
|
||||
[[ -z $TMUX ]] && tmux attach-session -t $1 || tmux switch-client -t $1
|
||||
}
|
||||
|
||||
hydrate() {
|
||||
tmux_hydrate() {
|
||||
local tmux_hydrate_files_dir="$XDG_CONFIG_HOME/tmux/session-hydrate-files"
|
||||
local tmux_hydrate_path="$tmux_hydrate_files_dir/.tmux-session-hydrate-default"
|
||||
[[ $1 = "thinking" ]] && tmux_hydrate_path="$tmux_hydrate_files_dir/.tmux-session-hydrate-thinking"
|
||||
@@ -13,28 +13,28 @@ hydrate() {
|
||||
[[ -f $tmux_hydrate_path ]] && tmux send-keys -t $1 "source $tmux_hydrate_path" c-M
|
||||
}
|
||||
|
||||
local existing_sessions=$([[ -n $(pgrep tmux) ]] && tmux list-sessions || echo '')
|
||||
local search_dirs=(
|
||||
tmux_existing_sessions=$([[ -n $(pgrep tmux) ]] && tmux list-sessions || echo '')
|
||||
tmux_search_dirs=(
|
||||
$DIR_HOME_BOX
|
||||
$DIR_DEV
|
||||
$DIR_GIT_PROJECTS/*
|
||||
)
|
||||
local target_name=''
|
||||
local target_path=''
|
||||
tmux_target_name=''
|
||||
tmux_target_path=''
|
||||
|
||||
[[ $# -eq 1 ]] && target_path=$1 ||
|
||||
target_path=$(find $search_dirs -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
[[ $# -eq 1 ]] && tmux_target_path=$1 ||
|
||||
tmux_target_path=$(find $tmux_search_dirs -mindepth 1 -maxdepth 1 -type d | fzf)
|
||||
|
||||
if [[ $target_path = "." ]]; then target_name=$(basename $(pwd)) && target_path=$(pwd);
|
||||
elif [[ $target_path = "hub" ]]; then target_name="hub" && target_path="$HOME";
|
||||
elif [[ $target_path = "thinking" ]]; then target_name="thinking" && target_path="$DIR_SCRATCH_NOTES";
|
||||
elif [[ $target_path = "listening" ]]; then target_name="listening" && target_path="$DIR_MUSIC";
|
||||
elif [[ -n $target_path ]]; then target_name=$(basename "$target_path" | tr . _);
|
||||
if [[ $tmux_target_path = "." ]]; then tmux_target_name=$(basename $(pwd)) && tmux_target_path=$(pwd);
|
||||
elif [[ $tmux_target_path = "hub" ]]; then tmux_target_name="hub" && tmux_target_path="$HOME";
|
||||
elif [[ $tmux_target_path = "thinking" ]]; then tmux_target_name="thinking" && tmux_target_path="$DIR_SCRATCH_NOTES";
|
||||
elif [[ $tmux_target_path = "listening" ]]; then tmux_target_name="listening" && tmux_target_path="$DIR_MUSIC";
|
||||
elif [[ -n $tmux_target_path ]]; then tmux_target_name=$(basename "$tmux_target_path" | tr . _);
|
||||
fi
|
||||
|
||||
[[ -z $target_name ]] && exit 0
|
||||
[[ -z $tmux_target_name ]] && exit 0
|
||||
|
||||
! (echo $existing_sessions | grep -q "$target_name") &&
|
||||
tmux new-session -d -s $target_name -c $target_path &&
|
||||
hydrate $target_name $target_path
|
||||
switch_to $target_name
|
||||
! (echo $tmux_existing_sessions | grep -q "$tmux_target_name") &&
|
||||
tmux new-session -d -s $tmux_target_name -c $tmux_target_path &&
|
||||
tmux_hydrate $tmux_target_name $tmux_target_path
|
||||
tmux_switch_to $tmux_target_name
|
||||
|
Reference in New Issue
Block a user