Skip to content

Instantly share code, notes, and snippets.

@chriscorwin
Last active January 26, 2017 16:16
Show Gist options
  • Select an option

  • Save chriscorwin/498ca6eaabdf135e1b57d45551efad9b to your computer and use it in GitHub Desktop.

Select an option

Save chriscorwin/498ca6eaabdf135e1b57d45551efad9b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
pbscript="/Users/ccorwin/Google Drive/Documents/pasteboard.js"
touch "${pbscript}"
pbpaste > "${pbscript}"
highlight -O rtf -t 2 -K 11 -k 'Source Code Pro' --syntax 'js' "${pbscript}" | pbcopy
echo -n "Enter gist filename and press [ENTER]: "
read gistfilename
if [[ -n "${gistfilename/[ ]*\n/}" ]]
then
#execute if the the variable is not empty and contains non space characters
echo "New filename is: ${gistfilename}";
gist --filename "${gistfilename}.js" --open "${pbscript}"
else
echo "Using default (foo) filename.";
#execute if the variable is empty or contains only spaces
gist --type js --open "${pbscript}"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment