1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
#!/bin/sh
# You probably want to stick the following into your .bash_profile:
# alias ev=~/crawl/crawl-ref/source/util/edit_vault
#
# You need to define $EDITOR as well; on Debian there's some weak-ass
# autodetection but that's unlikely to match _your_ preferences. And it
# may start something as vile as vi.
if [ -z "$1" ]
then
echo >&2 "Usage: edit-vault vault_name"
exit 1
fi
V=`grep -rHn --include='*.des' "NAME: *$1$"`
if [ -z "$V" ]
then
echo >&2 "Vault \"$1\" not found."
exit 1
fi
if which sensible-editor >/dev/null
then
ED=sensible-editor
else
ED="${EDITOR:-editor}"
fi
FILE="${V%%:*}"
LINE="${V#*:}"; LINE="${LINE%%:*}"
"$ED" +"$LINE" "$FILE"
|