Created
April 9, 2012 14:24
-
-
Save jblaine/2343796 to your computer and use it in GitHub Desktop.
Bourne shell function implementing https://github.com/oscardelben/sheet
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Bourne shell function implementing https://github.com/oscardelben/sheet | |
# with the exception of the 'embedded uri in sheets' feature (simply because | |
# I'm lazy and this is a proof of point exercise. | |
# | |
# Works anywhere with sh or bash | |
sheet () { | |
if [ "$1"x = "x" ]; then | |
ls -1 $HOME/.sheets 2> /dev/null || (mkdir $HOME/.sheets && echo "Created $HOME/.sheets") | |
return 0 | |
else | |
if [ "$1" = "edit" ]; then | |
shift | |
$EDITOR $HOME/.sheets/$1 | |
else | |
cat $HOME/.sheets/$1 2> /dev/null || echo "No sheet $1 to display. Create one with sheet edit $1" | |
fi | |
fi | |
} | |
EXAMPLE USAGE: | |
~:cairo> sheet | |
Created /home/jblaine/.sheets | |
~:cairo> sheet | |
~:cairo> sheet foo | |
No sheet foo to display. Create one with sheet edit foo | |
~:cairo> sheet edit foo | |
[ edit, save, close ] | |
~:cairo> sheet | |
foo | |
~:cairo> sheet foo | |
The contents of foo! | |
~:cairo> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Nice work. I'd have done the same if it wasn't for the fact that it'll be easier for me to extend functionality in the future by using Ruby (I know it better). I also think as code adds up bash code in general becomes harder to read.
This[1] for example, it's not exactly readable, and while that's only my fault, I preferred to make a script in ruby this time.
[1] https://github.com/oscardelben/git-diff-grep/blob/master/git-diff-grep