blog (1161B)
1 #!/bin/sh 2 3 die() { 4 echo "$1" >&2 5 exit 1 6 } 7 blogdir="/Users/alex/Documents/Programming/thezeroalpha.github.io/blog" 8 [ -d "$blogdir" ] || die "Blog directory does not exist" 9 if ! command -v tmux 1>/dev/null 2>&1; then 10 echo "tmux not installed." >&2 11 exit 1 12 fi 13 14 # Clear rbenv variables before starting tmux 15 unset RBENV_VERSION 16 unset RBENV_DIR 17 18 tmux start-server; 19 20 cd "$blogdir" || die "Cannot cd to $blogdir" 21 22 # Create the session and the first window. Manually switch to root 23 # directory if required to support tmux < 1.9 24 TMUX='' tmux new-session -d -s blog -n site 25 tmux send-keys -t blog:1 cd\ "$blogdir" C-m 26 27 28 # Create other windows. 29 tmux new-window -c "$blogdir" -t blog:2 -n post 30 tmux new-window -c "$blogdir" -t blog:3 -n server 31 32 33 # Window "site" 34 tmux send-keys -t blog:1 vim\ -o\ _layouts/default.html\ _sass/jekyll-theme-minimal.scss C-m 35 36 37 # Window "post" 38 tmux send-keys -t blog:2 vim C-m 39 40 41 # Window "server" 42 tmux send-keys -t blog:3 bundle\ exec\ jekyll\ serve\ --drafts C-m 43 44 45 tmux select-window -t blog:post 46 tmux select-pane -t blog:post.1 47 48 if [ -z "$TMUX" ]; then 49 exec tmux -u attach-session -t blog 50 else 51 exec tmux -u switch-client -t blog 52 fi