feat(scripts): rewrite script to fire tmux and fish with project home

This commit is contained in:
yeti 2025-05-16 13:03:16 +01:00
parent 6df5d05cc5
commit 6010c6a0ee

View File

@ -1,8 +1,30 @@
#!/bin/bash #!/usr/bin/env bash
set -euo pipefail
XDG_CONFIG_HOME="$PWD/.config" \ PWD="$(pwd -P)"
XDG_DATA_HOME="$PWD/.local/share" \
XDG_STATE_HOME="$PWD/.state" \ if [ "$(basename "$PWD")" != "workspaces" ]; then
XDG_CACHE_HOME="$PWD/.cache" \ echo "Error: this script must be run from a directory named 'workspaces', not '$(basename "$(pwd -P)")'" >&2
TMUX="" \ exit 1
tmux new-session -s dev -n editor 'nvim' fi
# Override PWD and HOME for this invocation
export PWD=$PWD
export HOME=$PWD
export TMUX=""
# Optionally adjust XDG_CONFIG_HOME if you use that
# export XDG_CONFIG_HOME="$HOME/.config"
# Start (or attach to) your dev session
SESSION="dev"
# If the session doesn't exist, create it
if ! tmux has-session -t "$SESSION" 2>/dev/null; then
tmux new-session -d -s "$SESSION" -n editor 'HOME='"$HOME"' XDG_STATE_HOME='"$HOME/.state"' /usr/bin/fish'
fi
tmux send-keys -t $SESSION:editor 'fisher install jorgebucaran/fisher pure-fish/pure patrickf1/fzf.fish jorgebucaran/autopair.fish gazorby/fish-abbreviation-tips jethrokuan/z' Enter
# Attach to it
exec tmux attach -t "$SESSION"