Zsh which alias




















No aliases or functions are concerned. Dr Eval, which "which"? Which Red Hat? Mikel RH7. GNU which v2. HalosGhost 4, 10 10 gold badges 30 30 silver badges 40 40 bronze badges. Meitham Meitham 5 5 bronze badges. Try the following: which --skip-alias vim.

SiegeX SiegeX 7, 3 3 gold badges 32 32 silver badges 23 23 bronze badges. This works on Bash, but not on Zsh I really didn't think this was going to be shell-dependent.

This made me realize that which is actually a shell built-in and not a regular Unix utility as I had assumed. So I should edit my question and specify Zsh. Thanks for pointing this out to me! It is a shell script, and part of debianutils, so works on zsh. However, --skip-alias is not an option the which on Debian.

Are there different varieties of which floating around? This does not apppear to be a standardized command. Faheem Mitha: It is a zsh builtin. See man zshbuiltins. Equivalent to whence -c. Yeah on Xubuntu's bash , it is not a built-in and doesn't have the --skip-alias option. As a result which which shows the alias, but command which which shows the executable!

Another alternative is command which vim , which works the same way in both zsh and bash E. Zee Alexander Zee Alexander 5 5 silver badges 6 6 bronze badges. Ah fair enough. Both type and which behave differently according to your shell type. More from ZSH manual. Simba Simba 1, 10 10 silver badges 12 12 bronze badges. Sign up or log in Sign up using Google.

When you try to use the alias anywhere else in the command, the alias will not work:. This is where zsh has an advantage. There is one more feature of zsh that is useful with aliases. The which command will show if a command stems from an alias substitution:. However, when you try this with global aliases, the substitution occurs before the which command can evaluate the alias, which leads to an unexpected result:.

You can suppress the alias substitution by escaping the first character or by quoting the entire alias name:. As with aliases, functions in your zsh configuration will work just as they did in bash.

This code in your zsh configuration file will define the vnc function and make it available in the shell. However, zsh has some features which make using functions more flexible. There is once again a bit of configuration required to get this working. Instead of declaring the function directly the configuration file, you can put the function in a separate file.

You can add your own directory to this search path:. Just having a file in the directory is not enough. You still have to tell zsh that you want to use this particular function:. To execute it, load a file named vnc , it is somewhere in the fpath.

Note: you often see the -U or -Uz option added to the autoload command. These options help avoid conflicts with your personal settings. They suppress alias substitution and ksh -style loading of functions, respectively.

I don't know if there are no functions because aliases can take parameters, or if aliases take parameters because there are no functions, or what. So you would call it from the shell like gitall "my commit message"? Show 1 more comment. So hacky and yet so beautiful — rococo. Why make an alias at all? Just call the function example. Also, belatedly, you need a semicolon before the closing brace. This was beautiful. With this I was able to make an alias that adds an alias to an rc file, then reloads said rc file.

Show 6 more comments. I used this function in. From command prompt run this command: gitall "commit message goes here" If we just run gitall without any commit message then the commit message will be update as the function said. Hasan Abdullah Hasan Abdullah 1, 1 1 gold badge 15 15 silver badges 33 33 bronze badges. Alberto Zaccagni Alberto Zaccagni 29k 10 10 gold badges 71 71 silver badges bronze badges. Timo Timo 2, 3 3 gold badges 21 21 silver badges 23 23 bronze badges.

Sign up or log in Sign up using Google. Sign up using Facebook. Sign up using Email and Password.



0コメント

  • 1000 / 1000