djui / alias-tips Goto Github PK
View Code? Open in Web Editor NEWAn oh-my-zsh plugin to help remembering those aliases you defined once
An oh-my-zsh plugin to help remembering those aliases you defined once
I get this error every time I run a command.
Hi, for some reason I'm getting a Python IndexError:
Traceback (most recent call last):
File "../djui/alias-tips-master/alias-tips", line 39, in <module>
main()
File "../djui/alias-tips-master/alias-tips", line 24, in main
aliases = get_aliases()
File "../djui/alias-tips-master/alias-tips", line 20, in get_aliases
return [(alias[0], alias[1].strip('\'')) for alias in aliases]
IndexError: list index out of range
Any idea why? I'm running Python 2.7.3 by the way.
Thanks.
I've found some unexpected "Alias for:" messages, especially while running particularly long commands:
$ echo longlonglonglonglonglonglong linelinelinelinelinelinelinelinelinelineline
Alias for: echo longlonglonglonglonglonglong linelinelinelinelinelinelinelinelinelinelin
longlonglonglonglonglonglong linelinelinelinelinelinelinelinelinelineline
I believe this is because the second argument to the preexec hook can be trimmed and what we really want is to compare the command with the third argument, which is not trimmed.
Another issue is with export
(maybe some other builtins too, but I've only seen export so far):
$ export TEST=x
Alias for: export TEST=x
This one is because expanded command for some reason has a trailing whitespace. I'm not sure, maybe this is actually a zsh bug, but we can easily workaround this by removing the trailing whitespace before doing comparison.
Would you be interested in PRs to fix that? Any objections to
CMD_EXPANDED=$3
instead of CMD_EXPANDED=$2
git: 'alias' is not a git command. See 'git --help'.
I think you have a git alias named "alias", but it is not working for me.
Pls use the real git command, I think it might be something like 'git config --get-regexp "^alias."'
Currently the following does not work:
# alias l=ls '-l -h -a'
# alias l=ls -lha'
$ ls -l -a -h foo
$ ls -lah foo
should be suggestion: l foo
.
The algorithm should change to a heuristic that in most cases finds the alias. What makes this non-trivial is at least:
--
must be respected as flag and argument terminator-foo
is indistinguishable from -f -o -o
for some commands but is actually --foo
for other commands-f bar
, --foo bar
, and --foo=bar
are not always identical depending on if -f|--foo
is and argument flag or bool flag.Acceptance criteria and constraints:
alias l=ls '-l -h -a'
are handled and not yet alias l=ls -lha'
.docker run foo -- -it
!= dr foo
(or dr foo --
) if alias alias dr='docker run -it'
defined.I have git itself aliased:
alias g=git
This causes git aliases not to be found.
That is, git status
will cause Alias tip: git st
, but g status
will not result in any message about aliases.
Is it possible to configure alias-tips so that g
is correctly interpreted as an alias to git
?
Hi there.
I've discovered that using alias-tips alongside the following alias provides the following error:
alias grep='rg -uu'
Error parsing regex near '.\+ () {$' at character offset 14: Empty regex groups (e.g., '()') are not allowed.
with this great plugin I can see my alias when typing 'git remote -v'.
This alias-tips plugin will show: grv. Great!
so now my question: wouldn't it be great to also show what I am actually aliassing?
so when I type 'grv', the Alias-Tips will output:
'git remote -v' . Would be very handy when I give a training, share my screen or even remember what I am actually doing ;-)
for example I have two alias
alias g='git'
alias gp = 'git push'
and then if i do g push
it won't show me the prompt that this is the same as gp
Hi, just wanted to let you know that I added a pull request to integrate alias-tips into prezto.
sorin-ionescu/prezto#1586
belak/prezto-contrib#10
With the right push we might be able to merge it into the main project.
zplug "djui/alias-tips" install alias-tips
, but no effects in shell.
how to config?
How about adding tips support for git's own aliases?
Say, I have a git alias c commit
.
So, if I run
git commit -m "new commit"
It would be nice if I got a message for that like:
Alias Tip: git c -m "new commit"
alias ll="ls -l"
.abbr import-aliases
.ll
. It's autoexpanded by zsh-abbr
.alias-tips
displays that I should use ll
, which I already did echo $shell_functions "\n" $git_aliases "\n" $shell_aliases | \
python ${_alias_tips__PLUGIN_DIR}/alias-tips.py $*
This echo doesn't print corresponding alias.
Hey! This plugin is almost exactly what I was looking for! Kudos 👍
But I'm missing something, which is the "reveal used alias" feature for git aliases.
After adding export ZSH_PLUGINS_ALIAS_TIPS_REVEAL=1
, it works fine for regular aliases
$ ll
Alias for: ls -G -lh
total 64
drwxr-xr-x 16 jose.armesto staff 512B 30 mar 21:49 .
drwxr-xr-x+ 125 jose.armesto staff 3,9K 31 mar 12:37 ..
drwxr-xr-x 16 jose.armesto staff 512B 31 mar 12:37 .git
-rw-r--r-- 1 jose.armesto staff 105B 23 may 2016 .gitignore
-rw-r--r-- 1 jose.armesto staff 4,8K 30 mar 21:39 CONTRIBUTING.md
-rw-r--r-- 1 jose.armesto staff 1,2K 30 mar 21:39 LICENSE.txt
-rw-r--r-- 1 jose.armesto staff 9,1K 30 mar 21:39 README.md
But it doesn't for git aliases
$ git dm
Alias tip: g dm
$ g dm
Alias for: git dm
I'd like to see this output
$ git dm
Alias for: !git branch --merged | grep -v '\*' | xargs -n 1 git branch -d
Since these are my git aliases
$ git alias
Alias tip: g alias
alias=!git config -l | grep ^alias | cut -c 7- | sort
amend=commit --amend --no-edit
dm=!git branch --merged | grep -v '\*' | xargs -n 1 git branch -d
Any ideas?
Should you define m
as an alias for make
, for example, then running makepkg
will prompt the plugin to remind you that there's an alias for that (mpkg
in this case) even though there's no such alias.
Hey I had the force alias tips working on my win10 wsl ubuntu setup. I reinstalled windows and the wsl system, but after reinstalling everything I noticed the force on aliases isn't working. Other stuff like export ZSH_PLUGINS_ALIAS_TIPS_REVEAL=1
still work, but not the force one.
I am using this awesome plugin from a long time but today I updated my Ubuntu 18.04 to Ubuntu 20.04. When I tried to source my .zshrc
this plugin got the following error:
_alias_tips__preexec:37: command not found: python
After a bit of googling, I found that Ubuntu 20.04 has removed the symlink to python2.x from /usr/bin/python
and now it only has python3
command available. Can someone help me how to resolve this issue? This error is coming again and again after every command I use.
I was looking at the test code and there's a lot of repetition. Consider using some sort of data-driven testing. It'll make the tests easier to write and work with.
Suggestions:
Let's define two "overlapping" aliases (I'm using these via https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/git)
alias g='git'
alias gsta='git stash save'
$ git stash save
Alias tip: g stash save
$ git stash save
Alias tip: gsta
gsta
is 4 characters and g stash save
is 12 characters, so gsta
should be preferred.
Sometimes it makes sense to define an alias with redirect(s) prefixed if additional arguments are prepended.
# alias ggb='2>/dev/null git gui'
$ 2>/dev/null git gui blame foo
$ git gui 2>/dev/null blame foo
$ git gui blame 2>/dev/null foo
$ git gui blame foo 2>/dev/null
Should all be suggestion ggb foo
.
One could imagine stripping the redirects for alias finding and then appending them again for the suggestion.
If two or more aliases are used for the same command, alias-tip gives me the other alias as tip.
When the function has special characters, this plugin will show up this error information output by grep
, this error was shown on every executed command, here is the key code line caused the error, it could be easily reproduced by using zsh-vi-mode at the same time.
On master any command I run gives a similar output:
_alias_tips__preexec:17: argument list too long: python
zsh: argument list too long: ls
rbenv:11: argument list too long: rbenv
rbenv:11: argument list too long: rbenv
prompt_background_jobs:1: argument list too long: wc
prompt_background_jobs:2: argument list too long: awk
If I checkout commit 5a2a92f
the problem goes away. Any ideas?
zsh version: 5.2
zplug version 2.1.0
to force me to use the aliases I setup.
Hi - thanks for the awesome plugin! I have an enhancement suggestion for you.
I use the oh-my-zsh git plugin, and I've already trained myself to always use g
instead of git
- which unfortunately means that alias-tips doesn't work for any git command that I type. (I assume because it doesn't expand g
-> git
before finding an alias matching the command.)
Here's an example:
→ repo:(master) g status
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
→ repo:(master) git status
Alias tip: gst
On branch master
Your branch is up-to-date with 'origin/master'.
nothing to commit, working directory clean
The relevant aliases from the git plugin:
alias g='git'
alias gst='git status'
Sounds tricky, but it would be really great if alias-tips expanded aliases inside commands.
I'm currently cleaning up my dotfiles, and noticed some weird issues when using pyenv. I use pyenv exclusively for my development stuff, and try to keep my global userspace as clean as possible.
Because of this, I narrowed down the following error message to this plugin:
Command 'python' not found, did you mean:
command 'python3' from deb python3
command 'python' from deb python-is-python3
This basically appears on my CLI after each command I run, until I manually load pyenv (by running pyenv) to activate the shim, at which point this plugin starts working.
It would be super cool if this plugin could work without relying on a system python.
Hello! Just installed this yesterday and am unsure if I am missing something as it doesn't seem to work as expected. I tried using the various config options to change the behavior but am currently stuck.
If I use a command that has an alias, such as npm i -g yarn
, I get a correct suggestion to use npmg yarn
instead. However, when I use that, I get the same suggestion. Would love to use the force option to force me to use aliases, but this currently means I can run no commands that have an alias.
Some sample output when I have force on:
❯ zshconfig
Alias tip: zshconfig
❯ zshconfig
Alias tip: zshconfig
❯ npmg yarn
Alias tip: npmg yarn
❯ nano ~/Dropbox/ohmyzsh/zshrc
Alias tip: nano ~/Dropbox/ohmyzsh/zshrc
The current options I have set in my .zshrc are:
# Alias-tips options
export ZSH_PLUGINS_ALIAS_TIPS_TEXT="Alias tip: "
export ZSH_PLUGINS_ALIAS_TIPS_EXCLUDES="ls"
export ZSH_PLUGINS_ALIAS_TIPS_EXPAND=1
export ZSH_PLUGINS_ALIAS_TIPS_FORCE=1
export ZSH_PLUGINS_ALIAS_TIPS_REVEAL=0
export ZSH_PLUGINS_ALIAS_TIPS_REVEAL_TEXT="Alias was: "
export ZSH_PLUGINS_ALIAS_TIPS_REVEAL_EXCLUDES=(ls)
Would love to use this plugin so any help would be appreciated!
Not that I want it but someone might someday. If so, this should be added.
Or if someone me feels bored and wants to extend this project.
I see functions are actively excluded, why is that? sometimes I use functions for better args parsing and sometimes I forget I made them :)
Recently getting this message on OSX:
~/htdocs
❯ which python
_alias_tips__preexec:34: command not found: python
python not found
~/htdocs
❯ which python3
_alias_tips__preexec:34: command not found: python
/opt/homebrew/bin/python3
I don't feel like I deserve that much punishment!
It would be nice to be able to ignore certain aliases. For example, if I have an alias to correct a common-typo, I don't want to be reminded of the typo if I type the correct command.
I love Alias tips, but it causes my startup time to take a severe hit, as shown by zprof
:
~> zprof
num calls time self name
-----------------------------------------------------------------------------------
1) 1 242.86 242.86 43.35% 242.86 242.86 43.35% _alias_tips__preexec
Is there any way to fix/optimize this? I am using oh-my-zsh.
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.