All Questions
24
questions
40
votes
2
answers
38k
views
alias vs export for simple commands
For simple commands like less, is it better to make an alias or to export the options? Is there any benefit of one over the other?
For example, if I want less to always use the -R option to show raw ...
25
votes
4
answers
15k
views
Share aliases and PATH setting between zsh and bash
The shell that I normally use is zsh. I have several aliases to enable color in some programs such as ls and grep. I've also set my custom path so that I can execute programs in non-standard place (...
11
votes
3
answers
6k
views
Difference between alias in zsh and alias in bash
I have searched around but could not find anything conclusive. Is there a difference between the alias command in zsh and the alias command in bash? If not, does it mean I can share a set of aliases ...
7
votes
5
answers
6k
views
Get the expansion of an alias (in both bash and zsh)
I want to get the expansion of an alias.
For example, if I have:
alias g=hub
alias cdh='cd $HOME'
I want to have:
expand_alias g == hub
expand_alias cdh == cd $HOME
The tricky thing is that the two ...
7
votes
5
answers
6k
views
Is it possible to define directory-sensitive aliases in zsh (or any other shell)?
I want to use different aliases (or perhaps: the same alias differently) depending on the current working directory. For example, I might want to use l as a shorthand for ls with some extra options. ...
5
votes
3
answers
6k
views
Automatically put an alias into ~/.bashrc or ~/.zshrc [duplicate]
Is there a command line util/script that automatically saves aliases? E.g.
save-alias my-ip="curl ipecho.net/plain"
and that will define an alias, then add/update it in ~/.bashrc or ~/.zshrc
I was ...
5
votes
2
answers
3k
views
Forward aliases to child process
I have some aliases which are defined in /etc/zprofile (or /etc/profile for bash). Also $PATH gets manipulated there.
I want to start an interactive shell from a shell which avoids the $PATH ...
4
votes
3
answers
2k
views
Automatically source a file when `cd` into a specific directory
I have couple of utility commands-and-aliases that are generic enough in any directory for my own requirement. But there are certain directory e.g. 'build', where I need a custom behaviour.
To do this,...
4
votes
4
answers
5k
views
Does Bash and Zsh have a mode to echo what the alias expands to upon pressing Enter?
For example, if I have a
alias dbmigrate='rails db:migrate'
is there a mode or simple way to configure in Bash and Zsh so that when I type in the shell:
$ dbmigrate # press Enter
it will echo ...
3
votes
1
answer
5k
views
How to create an alias for two Git commands that use a parameter? [duplicate]
I regularly have to delete a local and remote Git branch. Therefore, I run the following commands:
$ git branch -d feature-branch
$ git push --delete origin feature-branch
Since I mostly execute ...
3
votes
2
answers
944
views
How to create an alias that launches zathura with tabbed
So tabbed outputs it's xid when you run it. How could I put this into an alias dynamically?
I'm looking to do something like:
alias zathura = tabbed -c zathura -e ${tabbed Xid goes here} & disown
2
votes
2
answers
748
views
How to add an alias for 'git add **/'
I can't seem to add an alias for git add **/
I think those two asterisks is causing an issue, or it could be that forward slash. How do I solve this?
So far I have tried
alias ga='git add **/'
When ...
2
votes
1
answer
361
views
Alias piping into awk
I am trying to create an ll with awk pipe alias. I am trying to escape the apostrophes using the following answers.
alias lh= `ll -h | awk {'print $9, \"-\" ,$5, \"-\", $8, \"...
2
votes
1
answer
75
views
Alias + and - in zsh?
For years I've used + and - as aliases for pushd and popd in both csh and bash. I've finally given up on my Macs and want to switch to zsh but I haven't been able to find a way to make these aliases. ...
2
votes
0
answers
45
views
Can't unalias then redefine as a function in the same conditional [duplicate]
Here is a simplified implementation of an issue in my bash/zsh aliases file:
alias foobar='echo bar' # this is out of my control
if true; then
unalias foobar
echo we got inside the conditional
...