Skip to content

Commit ed657db

Browse files
committed
Fix abbreviations for fish 3.6
1 parent dc8c867 commit ed657db

File tree

3 files changed

+24
-6
lines changed

3 files changed

+24
-6
lines changed

abbreviations

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
# This file contains all the custom fish abbreviations that I enable.
2-
# The helpers/abbbrs.fish script reads it in and passes each non-comment
2+
# The helpers/abbrs.fish script reads it in and passes each non-comment
33
# line to abbr with --add or --erase depending on if it's during an install
44
# or uninstall
5+
#
6+
# Due to a change in 3.6.0 I can't used run abbr --add directly, instead the
7+
# abbreviations are written to ~/.config/fish/conf.d/abbreviations.fish which will
8+
# be loaded on shell start
59

610
# Quick edit access for Zephish plugin
711
EZ code ~/.local/share/omf/pkg/zephish

functions/add_history_entry.fish

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# See https://unix.stackexchange.com/questions/631733/how-to-write-a-command-to-history-in-fish-shell
2+
function add_history_entry --description "Adds a command to the shell history"
3+
begin
4+
# brew install flock
5+
flock 1
6+
and echo -- '- cmd:' (
7+
string replace -- \n \\n (string join ' ' $argv) | string replace \\ \\\\
8+
)
9+
and date +' when: %s'
10+
end >>$__fish_user_data_dir/fish_history
11+
and history merge
12+
atuin history start $argv >/dev/null
13+
end

helpers/abbrs.fish

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ begin
33
set -lx action $argv[1]
44
set -lx context (tint: 778899 [zephish/(status --current-filename)])
55

6-
if not test $action = "install"
7-
and not test $action = "uninstall"
6+
if not test $action = install
7+
and not test $action = uninstall
88
echo $context Invalid argument (bold: (tint: red $action)) passed to abbrs. Expects either (bold: (tint: cyan install)) or (bold: (tint: cyan uninstall))
99
exit 1
1010
end
1111

12+
echo "# Source from zephish/abbreviations" >~/.config/fish/conf.d/abbreviations.fish
1213
while read -la line
1314
if test "$line[1]" = "#"
1415
or test -z "$line"
1516
continue
1617
end
17-
if test $action = "install"
18-
abbr -a $line
18+
if test $action = install
19+
echo "abbr -a $line" >>~/.config/fish/conf.d/abbreviations.fish
1920
else
2021
abbr -e $line[1]
2122
end
2223
end <abbreviations
2324

24-
end
25+
end

0 commit comments

Comments
 (0)