Skip to content

Instantly share code, notes, and snippets.

@madx
Created October 23, 2009 07:49
Show Gist options
  • Save madx/216714 to your computer and use it in GitHub Desktop.
Save madx/216714 to your computer and use it in GitHub Desktop.
#!/bin/bash
ISSUES=/home/madx/repos/mine/bit/issues
function bit_nl() { nl -nln -w1 -s $@ }
function bit_before() {
line="$(bit_nl $ISSUES)"
}
function bit_chunk() {
}
function bit_after() {
}
case "$1" in
list)
echo "$ISSUES" | grep --color=never -P "#\d+ \[(_|~|X)\]"
;;
show)
start="$2"
end="$(( start + 1))"
NLISSUES="$(echo "$ISSUES" | nl -nln -w1 -s' ')"
start="$(
echo "$NLISSUES" | grep -P "^\d+ #$start" | sed 's/^\([0-9]\{1,\}\).*/\1/'
)"
end="$(
echo "$NLISSUES" | grep -P "^\d+ #$end" | sed 's/^\([0-9]\{1,\}\).*/\1/'
)"
if [ -z "$end" ]; then
end="$(( $(echo "$ISSUES" | wc -l) + 1 ))"
fi
len="$(( end - start ))"
echo "$ISSUES" | tail -n+$start | head -$len
;;
edit)
;;
*)
echo "unknown command '$command'"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment