[Surfraw-devel] [PATCH v2] Improve printing of elvi list
Jameson Rollins
jrollins at finestructure.net
Sun Aug 22 03:41:54 UTC 2010
This patch adds a new function, list_elvi, that improves the printing
of the elvi descriptions in two ways:
- Ignore scripts that end with '~'. This is useful for users who
maintain their own elvi, by ignoring editor turds. This could
probably be expanded to ignore other turd-like files as well.
- Improve listing of scripts that are actually just symbolic links to
other scripts. Scripts that are links are now displayed as such,
disambiguating them from the script they link to. This makes it
much nicer to maintain elvi shortcuts (such as wiki --> wikipedia).
---
surfraw.IN | 12 ++++++++++--
1 files changed, 10 insertions(+), 2 deletions(-)
mode change 100644 => 100755 surfraw.IN
diff --git a/surfraw.IN b/surfraw.IN
old mode 100644
new mode 100755
index 3c7a730..9cf5864
--- a/surfraw.IN
+++ b/surfraw.IN
@@ -310,6 +310,14 @@ w3_parse_option_hook () {
return 1
}
+list_elvi() {
+ local dir="$1"
+ sed -n 's/^.*elvis: \(.*\)$/\1/p' $(find "$dir" ! -type d ! -type l ! -name '*~' | sort)
+ for script in $(find "$dir" ! -type d -type l | sort) ; do
+ printf '%-16s--> %s\n' $(basename "$script") $(basename $(readlink "${script}"))
+ done
+}
+
w3_parse_option () {
opt="$1"
case "$opt" in
@@ -319,11 +327,11 @@ w3_parse_option () {
case "$opt" in
-browser=*) setopt SURFRAW_browser $optarg ;;
-elvi) echo " GLOBAL ELVI:"
- sed -n 's/^.*elvis: \(.*\)$/\1/p' $elvidir/*
+ list_elvi "$elvidir"
localelvidir=$(get_local_elvi_dir)
if [ -d "$localelvidir" ] && [ -n "$(ls "$localelvidir")" ]; then
echo " LOCAL ELVI:"
- sed -n 's/^.*elvis: \(.*\)$/\1/p' "$localelvidir/"*
+ list_elvi "$localelvidir"
fi
exit 0 ;;
-escape-url-args=*) setoptyn SURFRAW_escape_url_args $optarg ;;
--
1.7.1
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 835 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/surfraw-devel/attachments/20100821/05140ecf/attachment.pgp>
More information about the Surfraw-devel
mailing list