Skip to content

Instantly share code, notes, and snippets.

@patrickwelker
Last active December 27, 2015 16:19
Show Gist options
  • Save patrickwelker/7353822 to your computer and use it in GitHub Desktop.
Save patrickwelker/7353822 to your computer and use it in GitHub Desktop.
Script for starting a gollum wiki (from anywhere) in the background when developing with RVM.
#!/bin/bash
# Load RVM into a shell session *as a function*
if [[ -s "$HOME/.rvm/scripts/rvm" ]] ; then
# First try to load from a user install
source "$HOME/.rvm/scripts/rvm"
elif [[ -s "/usr/local/rvm/scripts/rvm" ]] ; then
# Then try to load from a root install
source "/usr/local/rvm/scripts/rvm"
else
printf "ERROR: An RVM installation was not found.\n"
fi
# Open project folder
cd "$HOME"/wiki/;
# In case loading RVM isn't enough (c.f. in a project specific gemset) uncomment the next line
# rvm use 1.9.3@wiki
# Start gollum on port 61001 and run it in the background
screen -dmS wiki "$HOME"/.rvm/gems/ruby-1.9.3-p448@wiki/bin/gollum --port 61001
@patrickwelker
Copy link
Author

Starting Gollum Shell Script

Script for starting a gollum wiki (from anywhere) in the background when developing with RVM.

The first part of the script checks if the RVM-Ruby environment is used instead of your login shell (see https://rvm.io/workflow/scripting/).

The second part is starting the wiki in the background with screen.

About screen

  • for checking all screens open in the background: screen -ls
  • for reconnecting to the wiki: screen -r wiki
    • leaving the wiki running and returning to the shell: ⌃A + D
    • closing the background screen: ⌃C

Notes

I tried to set the path to the script in a variable like in this excellent article Personal Wiki using GitHub and Gollum on OS X.
But the example code DIR="$( cd -P "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" didn't work for me. The above solution is running smoothly now with my setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment