Replies: 2 comments 3 replies
-
I agree the fish abbr expansion feature is cool. I don't have plans to add it to zsh-abbr.
Me too! Maybe you can parse the |
Beta Was this translation helpful? Give feedback.
-
First of all, @olets, thanks a lot for this plugin. I use it all the time. It's so much beter than aliases. @paldepind, regarding expanding I am looking for something similar, to expand to the output of a command. I want to expand I managed to do it in a hacky way by having a cron job regulary run a script that updates the abbreviation. I don't know if there is a better way? By the way, it uses the new cursor placement feature, which is very handy for 'eating' the trailing space. script#!/usr/bin/env bash
cur_date="$(date +'%F')"
abbr_file="${HOME}/.config/zsh-abbr/user-abbreviations"
sed -i '/cdate/d' "$abbr_file"
echo 'abbr -g "cdate"="'"$cur_date"'%"' >> "$abbr_file"
# Add cron job if not present yet
if ! grep -qs 'insert-current-date' < <(crontab -l); then
# shellcheck disable=2016
cron_line='0 * * * * $HOME/dotfiles/zsh/insert-current-date-abbreviation.sh'
(crontab -l 2>/dev/null; echo "$cron_line") | crontab -
printf "Added cron job to regularly replace 'cdate' abbreviation\n"
fi
exit 0 |
Beta Was this translation helpful? Give feedback.
-
In Fish it is possible to create an abbreviation that does not expand to a fixed string, but instead to the dynamic output of a function. Here is an example:
With this abbreviation the text
!!
will expand into the most recently typed history entry.As far as I can see this feature is not available in zsh-abbr. It's very useful, so I propose adding it to zsh-abbr.
I'm currently trying to port the command line utility projectdo to zsh, and it seems that I would need this feature in
zsh-abbr
to do so. If anyone knows of another way to achieve this in zsh I'd be interested to hear about it.Beta Was this translation helpful? Give feedback.
All reactions