ThorstenHans / blog-comments

0 stars 0 forks source link

5-types-of-zsh-aliases #3

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

5 Types Of ZSH Aliases You Should Know · Thorsten Hans' blog

In ZSH you can increase your productivity with aliases. This post explains 5 types of aliases that you should know. Boost your shell productivity now and make ZSH your own

https://www.thorsten-hans.com/5-types-of-zsh-aliases

mwaitzman commented 1 year ago

Those simple "navigational aliases" as you called them are unidiomatic and bad IMHO - you will never add anything to that command itself, so write it as a function that doesn't read the input args instead. This more clearly communicates that it isn't a shorthand prefix for a different command (as simple aliases are meant to be), but rather is the entire command in its own right. I think pretty much, if the command itself (so of course allowing piping and redirection and whatnot) will never have anything added to it, make it a function. I personally have just avoided using global aliases. If it's a raw substitution with input intended to be had only at the end, make it a simple alias. Anything else, you're going to need functions anyways.

Also the "Functions for Aliases With Parameters" are just functions, not aliases at all. Being pedantic here, but you included those OS-specific aliases after all, so...

1ucasdev commented 12 months ago

Thanks for the detailed information! So far I’ve figured out how to make an calculator history. I will continue to learn new technologies. Thank you!

komidawi commented 9 months ago

Hi, thanks for the article, it's good to know there is more than one alias available :) 

I've got just one remark related with "Use Aliases To Edit and Reload .zshrc" section and alias to source $HOME/.zshrc.

In ohmyzsh README it is discouraged to reload changes using source command. Instead, it is advised to run exec zsh.

You may have seen somewhere that when you make a change to your zshrc file, you need to reload it. The common wrong suggestion is to use "source ~/.zshrc". This may cause trouble because some things that are already in the zsh session haven't been removed (variables, functions, hooks...). It's also possible that you're repeatedly running an init script and causing more and more processes to start.

(https://github.com/ohmyzsh/ohmyzsh/wiki/FAQ#how-do-i-reload-the-zshrc-file)