Update .gitconfig Update .tmux.conf Update .config/DankMaterialShell/firefox.css Update .config/DankMaterialShell/plugin_settings.json Update .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankActions/DankActionsSettings.qml Update .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankActions/DankActionsWidget.qml Update .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/DankActions/plugin.json Update .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/index Update .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/refs/heads/master Update .config/DankMaterialShell/plugins/.repos/0026f1eba8dedaec/.git/refs/remotes/origin/master Update .config/DankMaterialShell/plugins/emojiLauncher/.git/refs/remotes/origin/main Update .config/DankMaterialShell/settings.json Update .config/alacritty/dank-theme.toml Update .config/ghostty/config Update .config/ghostty/themes/dankcolors Update .config/niri/dms/colors.kdl Update .config/nvim/lua/plugins/dankcolors.lua Update .config/pda/config.toml Update .local/bin/tmux-sessionizer
62 lines
1.7 KiB
Bash
62 lines
1.7 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
# Each entry: PATH|minDepth|maxDepth
|
|
SEARCH_SPECS=(
|
|
"$HOME/src/github|2|2" # username/repo
|
|
"$HOME/src/aur|1|1" # AUR pkgs
|
|
"$HOME/.config|0|1" # each folder in ~/.config
|
|
"$HOME/.local/bin|0|0"
|
|
)
|
|
|
|
# Optional: override via env, e.g.
|
|
# SESSIONIZER_SPECS="$HOME/work|1|2,$HOME/projects|2|2"
|
|
IFS=',' read -r -a _OVERRIDE <<< "${SESSIONIZER_SPECS:-}"
|
|
if [[ ${#_OVERRIDE[@]} -gt 0 && -n ${_OVERRIDE[0]} ]]; then
|
|
SEARCH_SPECS=("${_OVERRIDE[@]}")
|
|
fi
|
|
unset _OVERRIDE
|
|
|
|
collect() {
|
|
local path min max
|
|
for spec in "${SEARCH_SPECS[@]}"; do
|
|
IFS='|' read -r path min max <<<"$spec"
|
|
[[ -d $path ]] || continue
|
|
find "$path" -mindepth "$min" -maxdepth "$max" -type d 2>/dev/null
|
|
done
|
|
}
|
|
|
|
if [[ $# -eq 1 ]]; then
|
|
selected=$1
|
|
else
|
|
if command -v fd >/dev/null 2>&1; then
|
|
mapfile -t CANDIDATES < <(collect | sort -u)
|
|
selected=$(printf '%s\n' "${CANDIDATES[@]}" | fzf)
|
|
else
|
|
selected=$(collect | sort -u | fzf)
|
|
fi
|
|
fi
|
|
|
|
[[ -z ${selected:-} ]] && exit 0
|
|
|
|
selected_name=$(basename "$selected" | tr -c '[:alnum:]' '_' | sed 's/^_*$/'"sess_$(date +%s)"'/' | sed 's/_$//')
|
|
tmux_running=$(pgrep tmux || true)
|
|
|
|
if [[ -z ${TMUX:-} ]] && [[ -z $tmux_running ]]; then
|
|
exec tmux new-session -s "$selected_name" -c "$selected"
|
|
fi
|
|
|
|
if ! tmux has-session -t="$selected_name" 2>/dev/null; then
|
|
tmux new-session -ds "$selected_name" -c "$selected"
|
|
tmux rename-window -t "$selected_name:" "shell"
|
|
# tmux new-window -t "$selected_name:" -c "$selected" -n "neovim"
|
|
# tmux send-keys -t "$selected_name:neovim" "nvim" Enter
|
|
tmux select-window -t "$selected_name:shell"
|
|
fi
|
|
|
|
if [[ -z ${TMUX:-} ]]; then
|
|
tmux attach -t "$selected_name"
|
|
else
|
|
tmux switch-client -t "$selected_name"
|
|
fi
|
|
i
|