aboutsummaryrefslogtreecommitdiffhomepage
path: root/share/functions/abbr.fish
diff options
context:
space:
mode:
authorGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-11-16 23:12:41 +0800
committerGravatar David Adam <zanchey@ucc.gu.uwa.edu.au>2014-11-16 23:13:22 +0800
commit14fa48864a6af7766d53141a2b8711db13d77fd2 (patch)
treea2911d64f377451b4032c985494d3543c020f74d /share/functions/abbr.fish
parent206ea15b68c0a6677d1f4eb3d5f978fbaef42606 (diff)
abbr.fish: escape the output of abbr --show
Allows abbreviations containing embedded newlines, etc., to be displayed and exported properly. Work on #731.
Diffstat (limited to 'share/functions/abbr.fish')
-rw-r--r--share/functions/abbr.fish8
1 files changed, 7 insertions, 1 deletions
diff --git a/share/functions/abbr.fish b/share/functions/abbr.fish
index fdb6d6ae..393e8243 100644
--- a/share/functions/abbr.fish
+++ b/share/functions/abbr.fish
@@ -100,7 +100,9 @@ function abbr --description "Manage abbreviations"
case 'show'
for i in $fish_user_abbreviations
- echo abbr -a \'$i\'
+ # Disable newline splitting
+ set -lx IFS ''
+ echo abbr -a \'(__fish_abbr_escape $i)\'
end
return 0
@@ -114,6 +116,10 @@ function abbr --description "Manage abbreviations"
end
end
+function __fish_abbr_escape
+ echo $argv | sed -e s,\\\\,\\\\\\\\,g -e s,\',\\\\\',g
+end
+
function __fish_abbr_get_by_key
if not set -q argv[1]
echo "__fish_abbr_get_by_key: expected one argument, got none" >&2