aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions
diff options
context:
space:
mode:
authorGravatar axel <axel@liljencrantz.se>2006-11-20 09:27:34 +1000
committerGravatar axel <axel@liljencrantz.se>2006-11-20 09:27:34 +1000
commit372c811763ed9c57476418dafb402f96fc312be6 (patch)
tree50bae5fd0035fa4263002de27fc80b2cfa116a23 /share/functions
parentdd061b1ddabdd28fc2a114a8360a8ec30f3a6ac4 (diff)
Support bold and underlined characters in help output
darcs-hash:20061119232734-ac50b-d426980ee143b44065a3ea2afc7d3808174acd5f.gz
Diffstat (limited to 'share/functions')
-rw-r--r--share/functions/__fish_print_help.fish24
1 files changed, 22 insertions, 2 deletions
diff --git a/share/functions/__fish_print_help.fish b/share/functions/__fish_print_help.fish
index 88a35b4b..15d489b8 100644
--- a/share/functions/__fish_print_help.fish
+++ b/share/functions/__fish_print_help.fish
@@ -1,7 +1,27 @@
-function __fish_print_help
+function __fish_print_help -d (N_ "Print help message for the specified fish function or builtin")
+
+ # These two expressions take care of underlines (Should be italic)
+ set -l cmd1 s/_\x08'\(.\)'/(set_color --underline)\\1(set_color normal)/g
+ set -l cmd2 s/'\(.\)'\x08_/(set_color --underline)\\1(set_color normal)/g
+
+ # This expression should take care of bold characters. It's not
+ # waterproof, since it doesn't check that the same character is
+ # used both before and after the backspace, since regular
+ # languages don't allow backreferences.
+ set -l cmd3 s/.\x08'\(.\)'/(set_color --bold)\\1(set_color normal)/g
+
+ # Combine all expressions in a single variable
+ set -l sed_cmd -e $cmd1 -e $cmd2 -e $cmd3
+
+ # Render help output, save output into the variable 'help'
set -l help (nroff -man $__fish_datadir/man/$argv.1)
set -l lines (count $help)
+
+ # Print an empty line first
echo
- printf "%s\n" $help| tail -n (expr $lines - 5 ) | head -n (expr $lines - 8)
+
+ # Filter and print help
+ printf "%s\n" $help| tail -n (expr $lines - 5 ) | head -n (expr $lines - 8) | sed $sed_cmd
+
end \ No newline at end of file