.startup.sh

#46
Raw
Author
winny
Created
Sept. 8, 2020, 2:17 a.m.
Expires
Never
Size
1009 bytes
Hits
648
Syntax
Bash
Private
No
#!/usr/bin/env bash
# .startup.sh in my sillypaste project.  Starts up an Emacs frame with relevant
# files.  Also sets up the django webserver and an initialized python venv
# shell.  Finally it also fires up qutebrowser using my new-qb script with a
# custom profile for this project.
session='sillypaste'
project_directory="${0%/*}"

if ! cd "$project_directory"; then
    printf 'Could not cd into "%s"\n' "$project_directory" >&2
    exit 1
fi

emacsclient -c -n \
            /var/lib/syncthing/misc-sync/org/sillypaste.org \
            "${project_directory}/" \
            "${project_directory}/core" \
            "${project_directory}/web"

tmux new-session -s "$session" -d \
     'bash -c "pwd; . venv/bin/activate && python manage.py runserver 0.0.0.0:8000"' \; \
     set-option  remain-on-exit on \; \
     split-window -h \; \
     send-keys '. venv/bin/activate' 'C-j' 'C-j'
     
new-qb -p "$session" '127.0.0.1:8000' &> /dev/null & disown

exec tmux attach-session -t "$session"