workspaces/.bin/test-tmux.sh

31 lines
910 B
Bash
Executable File

#!/usr/bin/env bash
set -euo pipefail
PWD="$(pwd -P)"
if [ "$(basename "$PWD")" != "workspaces" ]; then
echo "Error: this script must be run from a directory named 'workspaces', not '$(basename "$(pwd -P)")'" >&2
exit 1
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"