Skip to content

Instantly share code, notes, and snippets.

@mhanberg
Created February 8, 2019 18:41
Show Gist options
  • Save mhanberg/1005b14cd1df51ee73b5d6c2332c498d to your computer and use it in GitHub Desktop.
Save mhanberg/1005b14cd1df51ee73b5d6c2332c498d to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
# Write a code snippet in your preferred editor, upload to a GitHub Gist,
# and then open the snippet in Carbon with the gist url in your clipboard.
#
# Remember to login first with `gist --login`
hash gist || exit 1
file_name=$1
temp_dir="/tmp/hot-tip"
file_path="$temp_dir/$file_name"
mkdir -p $temp_dir
$EDITOR "$file_path" || exit 1
printf "==> Uploading to a gist and saving url to clipboard...\n\n"
gist_url=$(gist --copy "$file_path")
printf "==> Opening carbon.now.sh...\n"
open "https://carbon.now.sh/$gist_url"
rm "$file_path"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment