olets / zsh-abbr Goto Github PK
View Code? Open in Web Editor NEWThe zsh manager for auto-expanding abbreviations, inspired by fish shell.
Home Page: https://zsh-abbr.olets.dev
License: Other
The zsh manager for auto-expanding abbreviations, inspired by fish shell.
Home Page: https://zsh-abbr.olets.dev
License: Other
open a terminal window and load this amazing plugin and then enter s then r then n then space:
$ srn
...and have it transformed as it was in v4:
$ sed -e ':a' -e 'N' -e '$! b a' -e 's/\n//g'
the text is transformed into the following since v5 (the escaped exclamation point is new)
$ sed -e ':a' -e 'N' -e '$\! b a' -e 's/\n//g'
printf \\41
. Here’s some examples I can’t force to work no matter the means I use to try and hide the !
from zsh-abbr and zsh: try filling your $ABBR_USER_ABBREVIATIONS_FILE
with the following, all of which worked fine in v4$ cat $ABBR_USER_ABBREVIATIONS_FILE
abbr one='find . ! -name example'
abbr two='sed -e '\'':a'\'' -e '\''N'\'' -e '\''$! b a'\'' -e '\''s/\n//g'\'''
abbr two='sed -e '\'':a ; N ; $! b a ; s/\n//g'\'''
abbr two='sed -e '\'':a ; N ; $! b a ; s/\n//g'\'''
abbr --global fng2="$(printf -- 'find -- . -mindepth 1 ! -name '\''.git'\'' ! -path '\''*/.git/*'\'' ! -name '\''.DS_Store'\''\n')"
abbr --global fng3='find -- . -mindepth 1 ! -name '\''.git'\'' ! -path '\''*/.git/*'\'' ! -name '\''.DS_Store'\'''
abbr --global fng='find -- . -mindepth 1 ! -name '\''.git'\'' ! -path '\''*/.git/*'\'' ! -name '\''.DS_Store'\'''
abbr --global srn='sed -e '\'':a; N; $! b a; s/\\n//g'\'''
find
where find . \! -path xyz
and find . ! -path xyz
are interpreted as the same command. It does however break an already-escaped exclamation pointcat $ABBR_USER_ABBREVIATIONS_FILE
abbr --global srn1='sed -e :a -e N -e \$\!b\ a -e s/\\\n//g'
which expands into the following, which includes a literal newline:
$ sed -e :a -e N -e \$\!b\ a -e s/\\
//g
zsh-abbr version 5.0.0
zsh 5.9 (x86_64-apple-darwin22.1.0)
OSTYPE darwin22.1.0
Using both iTerm (Build 3.5.20230225-nightly) and kitty (Build 3.5.20230225-nightly), getting the same results.
Manual
No response
Pretty sure the problem begins in either 30216ba7ba
or 2503546976
.
Thank you for this solid, serious, well-documented plugin.
I cloned the repo and tried to source zsh-abbr.zsh
. The shell was hanging for a looong time so I stopped it by ctrl+c
. Tried sourcing again and get the error message:
abbr: A job added at 16:20:54 Sep 10 2020 has timed out. The job was related to initialization. This could be the result of manually terminating an abbr activity, for example during session startup.
I uninstalled and tried again, but with same result.
I am using zsh 5.4.2 (with prezto) on ubuntu on WSL2.
Is it possible to add is a a module in prezto?
Hey,
i updated my fedora system yesterday from 31 to 32.
Before the update it was possible for me to use the abbreviations via tabbing. E.g. typing vp
, hitting TAB and zsh shows my abbreviation vprov
(for vagrant provision
).
Since the update this is no longer the case.
The abbreviations work as expected (typing vprov
auto-expands to vagrant provision
after hitting space or enter).
I'm not sure where i have too look for the cause of this issue.
➜ abbr version
zsh-abbr version 4.2.0
➜ zsh --version
zsh 5.8 (x86_64-redhat-linux-gnu
Reinstalled abbr already (installed via brew now), but this has not fixed the issue.
error is as follows:
==> Installing zsh-abbr from olets/tap
==> Downloading https://github.com/olets/zsh-abbr/releases/download/v4.1.0/v4.1.0.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/167840485/a486e300-1620-11eb-94a5-c244f3169fc6?X-Amz-Algorithm=AWS4-HMAC-S
######################################################################## 100.0%
Error: SHA256 mismatch
Expected: 44fafc4
Actual: bacc95a9c65faf851a3009641885fae0b2ae9a80ade1aa7892e200ee6c399294
Archive: /Users/USERNAMEREDACTED/Library/Caches/Homebrew/downloads/be31d708fcd84ff43e0cdd759ce4234827c06f437125a37858ff364650658ea3--v4.1.0.tar.gz
To retry an incomplete download, remove the file above.
I removed the file mbut it makes no difference.
Hi there, people who have reported zsh-abbr bugs.
I'm adding https://allcontributors.org/ to the zsh-abbr documentation. For now the list will show at https://zsh-abbr.olets.dev/community/ and in the README (e.g. https://github.com/olets/zsh-abbr#community).
Despite managing this list with a tool that has the word "contributors" in its name, this "community" is not "contributors" in the licensing sense.
If you'd like to be included in the community list, give this comment a thumbs up. I'll follow up with an allcontributors PR that you can review.
If you don't want to be included, do nothing or give a thumbs down.
To keep this from spamming everyone with notifications,
👇
👆
I'll check the issue for new thumbs ups periodically, and will close it in a month. If the issue is closed, I've stopped checking for thumbs ups. At that point, commenting is the appropriate way to say you'd like to be added.
(I recommend unsubscribing, to avoid any comment notifications from late comers.)
Thanks!
Autosuggestion for abbreviations doesn't work. #20 suggests that it's intentional. But there are some use cases, where it can be useful. Is there any chance it will be implemented?
abbr -g a="abc"
a[Space] # expands
b a[Space] # expands
[[ a[Space] # expands
(( a[Space] # does not expand 😞
$( a[Space] # does not expand 😞
This is due to how zsh parses strings containing ((
.
% mytest() {
local words=(${(z)1})
local count=${#words}
local word_count=${(w)#words}
echo $count
echo $word_count
echo $words[-1]
echo ${(w)words: -1}
}
% mytest "a"
1
1
a
a
% mytest "a b"
2
2
b
b
% mytest "[[ a"
2
2
a
a
% mytest "(( a"
1
2
(( a
(( a
wontfix
because I'm okay living with this, help wanted
because ideas are welcome. I do want to rely on zsh's shell grammar parsing and word splitting (retreating to pre-a3c00f5 is not a solution).
Would be nice to support fast-syntax-highlighting.
Its chroma docs are here.
Hi, I think it wil ge great to support variable evaluation when expanding abbreviation.
For example:
Given password=mysecret
abbr cflogin='cf login -p ${password} -o myOrg -s mySpace'
That would be awesome if we can skip alias-tips
repo suggestions if the command is coming from zsh-abbr
Does it make sense to use both? Thoughts?
abbr add --force …
will overwrite a conflicting abbreviation is one is already present.
add
does not know about --force
Your recent change 0311ecf added these lines to zsh-addr.zsh:
_zsh_abbr_command() {
\command \command $@
}
This causes the error in the title because I don't have a binary called 'command' in my path.
_abbr_job_push:add_job:7: permission denied: /tmp/zsh-abbr/jobs/1646859860.17046
_abbr_job_push:wait_turn:3: bad math expression: operand expected at end of string
I don't really know any other way to describe this but segfault :)
'builtin' 'echo' $job_description > ${ABBR_TMPDIR}jobs/$job_name
next_job_age=$(( $(date +%s) - ${next_job%.*} ))
These are the two problematic lines. Looks like the second one is caused by the first.
I don't really know what to do about that permission denied
. Denied by what? Permissions?
I added the following abbreviation with single quotes. It worked fine in that terminal session.
❯ abbr -a nodes='echo "MASTERS" && kubectl get nodes --selector="kubernetes.io/role=master" && echo "REGULAR NODES" && kubectl get nodes --selector="kubernetes.io/role!=master,dedicated!=heavy" && echo "HEAVY NODES" && kubectl get nodes --selector="kubernetes.io/role!=master,dedicated=heavy"'
When I opened a new terminal I hit this error....
[WARNING]: Console output during zsh initialization detected.
abbr add: Expected one argument, got nodes=echo MASTERS && kubectl get nodes --selector=kubernetes.io/role=master && echo REGULAR NODES && kubectl get nodes --selector=kubernetes.io/role!=master,dedicated!=heavy && echo HEAVY NODES && kubectl get nodes --selector=kubernetes.io/role!=master,dedicated=heavy
Trying to delete it fails...
❯ abbr -e nodes
abbr erase: No matching abbreviation nodes exists
For help run abbr --help
==> Upgrading olets/tap/zsh-abbr 4.2.0 -> 4.2.1 ==> Downloading https://github.com/olets/zsh-abbr/releases/download/v4.2.1/v4.2.1.tar.gz ##O#- # curl: (22) The requested URL returned error: 404 Error: Failed to download resource "zsh-abbr" Download failed: https://github.com/olets/zsh-abbr/releases/download/v4.2.1/v4.2.1.tar.gz
No bindary .zwc files present in repo. Follow-up to #65
https://github.com/olets/zsh-abbr/blob/main/tests/tests.plugin.zsh.zwc is present in repo.
{
emulate -LR zsh
setopt local_options extended_glob
autoload -Uz zrecompile
for plugin_file in zsh-abbr/**/*.zsh{-theme,}(#q.); do
zrecompile -pq "${plugin_file}"
done
}
tests/tests.plugin.zsh.zwc
Irrelevant.
Manual
git clone
No response
I've installed zsh-abbr
using oh-my-zsh
:
$ git clone https://github.com/olets/zsh-abbr.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-abbr
And added it to my plugins list in .zshrc
:
plugins=(
git
common-aliases
---snip---
zsh-syntax-highlighting
zsh-abbr
)
source $ZSH/oh-my-zsh.sh
Then I ran abbr import-aliases
and they were successfully imported, but weren't working even after I restarted zsh
, commented out all the other plugins I have and re-imported aliases.
The solution to this problem is just
$ source $ZSH_CUSTOM/plugins/zsh-abbr/zsh-abbr.zsh
but isn't there more elegant solution? Should I just add the line above to my .zshrc
? (I thought oh-my-zsh
were doing exactly that -- source
ing plugins' scripts?)
There is no tar ball for v4.8 on GitHub Releases.
Please publish the new version.
Formula specifies an URL below, but the file is not found.
https://github.com/olets/zsh-abbr/releases/download/v4.8.0/v4.8.0.tar.gz
I'd like to define abbr as follows.
abbr add --quiet -g gr='$(git rev-parse --show-cdup)'
ref:
https://github.com/momo-lab/zsh-abbrev-alias#help
-e, --eval evaluates subshells on expansion.
I believe those files were committed by mistake. History doesn't hint any reason why they we added in the first place, and they aren't following changes in .zsh files:
As you may know .zwc is compiled script, internal representation of which depends zsh version, machine architecture and probably some other factors. So it doesn't make sense to keep .zwc files in repo, users who need them are able to generate them locally.
Unfortunately, even with my fixes to the mktemp
invocations in #1, the program fails to run with the following error:
$ abbr --version
_zsh_abbr:608: command not found: create_aliases
I'm running zsh 5.7.1 on arch linux. Any advice would be appreciated. I've been looking for something exactly like this plugin as I really liked fish's abbreviations but was annoyed by other aspects of fish.
I have aliases that look like this in my .gitconfig
.
[alias]
wkadd = ! "f() { \n\
git worktree add ../$(echo \"$1\" | sed \"s./.--.g\") $2 -b $1 && \n\
echo \"$2\" | grep -qv \"^origin/\" || git branch --unset-upstream $1; \n\
}; f"
When I run abbr import-git-aliases
, I get output like this.
Did not import the Git alias `wkadd` because its expansion is a function
Added the global user abbreviation `g$' '$' 'git`
Added the regular user abbreviation `$' '$' 'git`
Added the global user abbreviation `g$' '$' 'echo`
Added the regular user abbreviation `$' '$' 'echo`
Added the global user abbreviation `g$' '$' '\}\;`
Added the regular user abbreviation `$' '$' '\}\;`
The first line of course makes sense, but the rest don't.
import-git-aliases
should probably be made more aware of multiline aliases so that it knows to skip the whole alias definition if it finds a function alias, and not just the first line of it.
No response
No response
No response
.
Plugin manager
No response
No response
See #5 (comment)
❯ c_zsh_abbr_expand_widget:11: command not found: _zsh_highlight
Not really an issue. I noticed you have TODO items about autosuggestions and highlighting. Here are snippets I use to with zsh-autosuggestions and zsh-syntax-highlighting to better work with zsh-abbr. Hopefully they might be useful for you.
Enable regexp
highlighter and add pattern that matches abbreviations as 'words' to highlight them as you like.
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main regexp)
# highlight known abbreviations
typeset -A ZSH_HIGHLIGHT_REGEXP
# regexp matches abbreviations only when they standalone word, but not part of other words
ZSH_HIGHLIGHT_REGEXP+=('(^| )('${(j:|:)${(k)ABBR_REGULAR_USER_ABBREVIATIONS}}')($| )' 'fg=blue')
Disable showing autosuggestion after abbreviations. Also I don't think autosuggesting the abbreviations make much sense as they are usually just 2-3 symbols.
# Don't show suggestions after abbreviations
ZSH_AUTOSUGGEST_HISTORY_IGNORE=${(j:|:)${(k)ABBR_REGULAR_USER_ABBREVIATIONS}}
ZSH_AUTOSUGGEST_COMPLETION_IGNORE=${ZSH_AUTOSUGGEST_HISTORY_IGNORE}
What is the exact syntax for scopes?
The documentation says
abbr [<SCOPE>] [<TYPE>] <COMMAND> [<ARGS>]
and I tried the following:
❯❯❯ abbr -S session add v=vim
abbr add: Expected one argument, got 2: add v=vim
❯❯❯ abbr session add v=vim
abbr add: Expected one argument, got 2: add v=vim
❯❯❯ abbr -S session add
abbr add: Requires abbreviation and expansion
❯❯❯ abbr -S session add v vim
abbr add: Expected one argument, got 3: add v vim
None of these works, so I think this could be simply a bug.
I'm finding that zsh-abbr is expanding words found within the command.
For instance, in fish shell I had abbrs for "master" and "pods", but not I can't use these words in other commands.
Typing "pods" expands to "kubectl get pods", but if I press the up arrow to re-run, it expands to "kubectl get kubectl get pods", which then fails.
Instead, should the expansion only happen for the first word in the string, which I think it what fish does.
A new issue should be created
Don't know yet!
% echo this should
% echo be a "shell" code block
Other
more here
x
Hi, thanks for a great plugin!
Yesterday I came across this post on Reddit: Is there a way to get the macOS Text Substitutes feature working in Terminal?
It was a fun challenge, and this is what I ended up with:
while IFS="=" read -r key value; do
abbr add --session --global --quiet "$key"="$value"
done < <(defaults read ~/Library/Preferences/.GlobalPreferences.plist NSUserDictionaryReplacementItems | plutil -convert json -o - - | jq -r "map({ (.replace): .with}) | add | to_entries | map(\"\(.key)=\(.value|tostring)\")|.[]")
I have no idea if this is just a fun gimmick, or something a lot of Mac users would like to have. I just thought I'd share it here and let you decide.
Also, I haven't really used plutil
or jq
before, so there's probably cleaner ways of massaging the plist entries into a usable format.
Thank you for your work on this plugin! It's an essential one for me, coming from Fish. That said, it's also by far the slowest Zsh plugin I use and I was wondering if there's a performance tuning effort on the roadmap, if you've identified places where focusing on performance would have the biggest impact, or if you would accept PRs that address performance tuning?
When running /usr/bin/time zsh -i -c exit
, my Zsh startup times jump from 0.10 real 0.05 user 0.03 sys
to 0.29 real 0.13 user 0.13 sys
when adding zsh-abbr. I use about 20 other plugins if that gives some context. Perhaps I'm spoiled by Fish's speed, but anything over .15 can feel really sluggish.
I have had great luck loading this plugin via zsh-defer, which waits until Zle is idle to do the work of loading a plugin, thus getting you to a prompt quicker. My times then drop to 0.05 real 0.02 user 0.02 sys
. I think this is similar to what zinit does, but not everyone likes/uses zinit.
An alternative to performance tuning the existing code might be to carve out the core concepts from zsh-defer and implement a mini-defer within zsh-abbr itself to accomplish the same thing without changing any other code. I'm happy to help, but don't want to go down the wrong path here if some thought has already gone into how to achieve better performance from this plugin.
Again, thank you so much for the work on this!
As a reference, this is my topline zprof
results:
num calls time self name
-----------------------------------------------------------------------------------
1) 47 147.62 3.14 64.41% 140.42 2.99 61.27% _abbr:util_add
2) 1 24.53 24.53 10.70% 24.52 24.52 10.70% _abbr_deprecations:widgets
3) 48 10.84 0.23 4.73% 10.84 0.23 4.73% _abbr_no_color
4) 47 171.99 3.66 75.05% 10.36 0.22 4.52% _abbr
5) 1 229.18 229.18 100.00% 10.28 10.28 4.49% _abbr_init
6) 1 9.83 9.83 4.29% 9.83 9.83 4.29% _abbr_job_push:wait_turn
7) 294 4.42 0.02 1.93% 4.42 0.02 1.93% _abbr_debugger
8) 1 177.28 177.28 77.35% 3.07 3.07 1.34% _abbr_load_user_abbreviations:load
9) 1 2.88 2.88 1.26% 2.87 2.87 1.25% _abbr_job_pop
10) 47 151.10 3.21 65.93% 2.82 0.06 1.23% _abbr:add
11) 47 3.06 0.07 1.34% 2.12 0.05 0.92% _abbr:util_check_command
12) 47 174.20 3.71 76.01% 1.66 0.04 0.72% abbr
13) 1 1.42 1.42 0.62% 1.42 1.42 0.62% colors
14) 47 2.15 0.05 0.94% 1.19 0.03 0.52% _abbr:util_sync_user
15) 1 11.20 11.20 4.89% 1.03 1.03 0.45% _abbr_job_push
16) 47 1.43 0.03 0.62% 0.83 0.02 0.36% _abbr:util_log_unless_quiet
17) 1 177.92 177.92 77.63% 0.49 0.49 0.21% _abbr_load_user_abbreviations
18) 1 24.87 24.87 10.85% 0.33 0.33 0.14% _abbr_deprecations
19) 1 0.32 0.32 0.14% 0.31 0.31 0.13% _abbr_job_push:add_job
20) 1 0.15 0.15 0.06% 0.15 0.15 0.06% add-zsh-hook
21) 1 0.09 0.09 0.04% 0.07 0.07 0.03% _abbr_create_files
22) 1 0.08 0.08 0.03% 0.07 0.07 0.03% _abbr_bind_widgets
23) 1 0.05 0.05 0.02% 0.04 0.04 0.02% _abbr_add_widgets
24) 1 0.14 0.14 0.06% 0.03 0.03 0.01% _abbr_load_user_abbreviations:setup
I am using zsh-abbr for a while now and have an issue. And I just updated it from git directly; also zsh --version
: "zsh 5.8 (x86_64-pc-linux-gnu)".
For me the abbreviations won't triggered or expanded after a pipe |
. Like in this case: x
expands to chmod +x
, but chmod +x | x
does not. This can be solved with a global option -g
. The only problem is, that the abbr is really global and will even get triggered as an argument, like there: grep x file
to grep chmod +x file
. I would like to have an option that is less global and only affects as a command name, even after a pipe.
There is no tar ball for v4.8.2 on GitHub Releases.
Please publish the new version.
Formula specifies an URL below, but the file is not found.
https://github.com/olets/zsh-abbr/releases/download/v4.8.2/v4.8.2.tar.gz
When multiple sessions are initializing at the same time, it's possible for the initializations to collide. Common symptoms are one terminal giving the error
util_add:source:45: no such file or directory: …/zsh-user-global-abbreviations
and another terminal giving for each user abbreviation the warning
abbr add: A matching abbreviation … already exists
These are false positives: in my testing, all sessions do end up with all the user abbreviations available.
Until this is addressed, users can work around it by letting one session load before opening another.
I don't really like using import-git-aliases
as it produces too many conflicts with other commands. What I think would be really fantastic is if zsh-abbr could be clever enough to expand regular Git aliases contextually, i.e. when prefixed with the command git
.
$ abbr add --git fp='fetch --prune'
$ git fp<space>
# expands inline to
$ git fetch --prune
What would it take to implement this? I see this in _abbr_widget_expand
:
Lines 1236 to 1242 in ccac4d0
I suppose we'd need another layer here, something like _abbr_git_expansion
, which takes place only if $words[0] == 'git'
. I tried this, but even though Zsh arrays are 1-indexed, haha._abbr_git_expansion fp
prints fetch --prune
, typing git fp<space>
doesn't expand. What am I missing?
Hi there, people who have made commits to zsh-abbr.
I'm considering adding https://allcontributors.org/ to the zsh-abbr documentation. The current plan, which I may change in the future, is for the list to show at https://zsh-abbr.olets.dev/community/ and in the README (e.g. https://github.com/olets/zsh-abbr/tree/v5#community).
Despite managing this list with a tool that has the word "contributors" in its name, this "community" is not "contributors" in the licensing sense. For now, however, I am restricting the list to those people who have committed. edit: #83
If you'd like to be included in the community list, give this comment a thumbs up. I'll follow up with an allcontributors PR that you can review.
If you don't want to be included, do nothing or give a thumbs down.
To keep this from spamming everyone with notifications,
👇
👆
I'll check the issue for new thumbs ups periodically, and will close it in a month. If the issue is closed, I've stopped checking for thumbs ups. At that point, commenting is the appropriate way to say you'd like to be added.
(I recommend unsubscribing, to avoid any comment notifications from late comers.)
Thanks!
p.s. sorry if you're getting notifications because of those commits. Didn't know GitHub is so eager about linkification
A coworker tried installing with Homebrew and got an error. They then switched to use a plugin manager and that worked. Investigate…
The branch master
has been deleted. Maintaining it complicated the zsh-abbr devops.
main
has been the default branch for years.
Early adopters who use Homebrew to install zsh-abbr may initially have used master
. In my testing Homebrew is good about handling a change in default branch + deletion of the old default branch.
I have not tested every possible zsh plugin manager.
If you get an error like
fatal: Couldn't find remote ref refs/heads/master
or
pathspec 'master' did not match any file(s) known to git
you'll need to change the branch to main
.
If you've specified master
somewhere, change that to main
.
If you didn't specify master
somewhere, or if changing it didn't help, try checking out the branch main
:
cd $ABBR_SOURCE_PATH
git checkout main
🎉 If you have a success story, share you method here with installation method and steps taken.
😞 If you have trouble, let me know here.
Check the branch:next ROADMAP.md to see what work is underway or planned.
I recently discovered a really nice ls
replacement. Naturally, I did an alias ls=exa
straight away... and my next terminal hung like crazy.
It turns out the problem is in _zsh_abbr_job_push:next_job_id()
, where the behavior of ls -t
is assumed to be constant. Unfortunately, exa's -t
flag works very similarly, but doesn't have a default.
A straightforward fix would be to use \ls
instead, but I don't know how that meshes with the project's practices.
Occasionally —possibly related to putting my computer to sleep and then waking it up again— I get a warning about a missing temp file. It's added to the rbuffer
For example:
# when the terminal loads
% _abbr_global_expansion:source:12: no such file or directory: /var/folders/xn/26nbvw6s6n30pfwf7rmz4tfw0000gn/T/zsh-abbr/global-user-abbreviations
# when I then type `exec zsh`
% exec zsh_abbr_global_expansion:source:12: no such file or directory: /var/folders/xn/26nbvw6s6n30pfwf7rmz4tfw0000gn/T/zsh-abbr/global-user-abbreviations
# at this point, hitting ENTER to accept the line runs `exec zsh`, which resolves the problem
ZSH_HIGHLIGHT_REGEXP+=('^[[:blank:][:space:]]*('"${(j:|:)${(k)ABBR_REGULAR_USER_ABBREVIATIONS}}"')$' style)
ZSH_HIGHLIGHT_REGEXP+=('<('"${(j:|:)${(k)ABBR_GLOBAL_USER_ABBREVIATIONS}}"')$' style)
Those regex expressions aren't working for me on linux (style is appropriately adjusted of course)
echo "${(j:|:)${(k)ABBR_REGULAR_USER_ABBREVIATIONS}}"
gives me an array separated by whitespaces of my abbreviations, but they are not getting matched and highlighted.
I am calling aforementioned ZSH_HIGHLIGHT_REGEXP+=[...] after
source $HOME/.config/zsh/zsh-abbr/zsh-abbr.zsh
typeset -A ZSH_HIGHLIGHT_REGEXP
ZSH_HIGHLIGHT_HIGHLIGHTERS+=(main regexp)
in my .zshrc according to the zsh-syntax-highlighting documentation
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/regexp.md
When I use an alias, e.g. alias gst="git status"
, zsh-syntax-highlighting shows if it is a valid command/alias like this:
When I define the same with zsh-abbr
it looks invalid:
Is it possible to get the same validation with zsh-abbr
?
I installed zsh-abbr without having zsh-autosuggestions installed. The call to _zsh_autosuggest_clear
therefore caused an error to be printed in the shell frequently (when _abbr_widget_expand_and_accept
is called).
I solved this with the following change, but I'm sure there are better ways:
--- zsh-abbr.zsh.old 2020-10-29 10:42:06.000000000 -0700
+++ zsh-abbr.zsh 2020-10-29 10:42:40.000000000 -0700
@@ -1260,7 +1260,10 @@
zle _abbr_widget_expand
fi
- _zsh_autosuggest_clear
+ # https://unix.stackexchange.com/questions/332005/test-for-functions-existence-that-can-work-on-both-bash-and-zsh/332010
+ if type '_zsh_autosuggest_clear' 2>/dev/null | grep -q 'function'; then
+ _zsh_autosuggest_clear
+ fi
zle accept-line
}
Like fish's abbr, zsh-abbr supports interactive creation of persistent abbreviations that are immediately available in all terminal sessions and.
Like abbr gico=git commit -m "$1"
and then jump to position $1 after expanding.
I do apologize if zsh-abbr is not at fault here, I am still a ZSH newbie who recently migrated from Fish..
What I am here to report today is that whenbindkey -M main "^M" abbr-expand-and-accept
is used, the suggestions provided by zsh-autosuggestions would still be printed after the entered command even though it was never accepted.
And after some experimentation + searching I stumbled upon bindkey -M main "^M" accept-line
which happens to solve the issue but at the cost of having no abbr on Enter.
I obviously do not know what the appropriate solution to this issue is and therefore I am here to request help from someone who is more knowledgeable than myself!
re: #3 (comment):
I just made an AUR package for my own use by the way.
@ifreund awesome!
"for my own use"… Is it something that will work for all Arch users? If so it'd be great to add in the package installation section of the readme.
Really like the idea of having an AUR. What do you think the best way to keep the package updated is? I can't register with aur.archlinux.org without actually having Arch (or, I suppose, without lying about the pacman output for the anti-bot command), so I can't even flag a package as being out of date. Are you up for continuing to maintain it? I could ping you about releases.
e.g. abbr -g x=y
would highlight
When running abbr c
/ abbr clear-session
I'm expecting all abbr to be wiped. My use case being to run abbr c; abbr import-aliases
to get rid of old and add new aliases to abbr.
All other commands seem to work fine. The actual plugin works as expected, its just deleting the abbr which is tedious. I can delete with abbr erase <name>
, just not abbr c.
Basic zsh install (no oh-my-zsh) w/ Zplug as the plugin manager running on MacOS ventura.
zsh-abbr version 5.0.1
zsh 5.9 (arm-apple-darwin22.1.0)
OSTYPE darwin22.0
Other
brew tap "olets/tap"
brew install zplug olets/tap/zsh-abbr # & zsh of course
ZPlug setup
#!/usr/bin/env zsh
# as a part of your dotfiles setup/linking/stowing script
source /opt/homebrew/opt/zplug/init.zsh;
zplug "olets/zsh-abbr";
zplug install;
# .zshrc
source /opt/homebrew/opt/zplug/init.zsh;
zplug "olets/zsh-abbr";
zplug load;
No response
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.