File: edit_vault

package info (click to toggle)
crawl 2%3A0.34.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 100,188 kB
  • sloc: cpp: 363,709; ansic: 27,765; javascript: 9,516; python: 8,463; perl: 3,293; java: 3,132; xml: 2,380; makefile: 1,835; sh: 611; objc: 250; cs: 15; sed: 9; lisp: 3
file content (33 lines) | stat: -rwxr-xr-x 694 bytes parent folder | download | duplicates (6)
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"