All Questions
24
questions
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
...
1
vote
2
answers
124
views
alias defined in .zshrc does not propagate to shell script
I have python installed on my system as python3. In my .zshrc file I defined following alias:
alias python=python3
With this, I am able to run python3 using python on the command-line:
$ python
...
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
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, \"...
1
vote
0
answers
116
views
can we trigger some action if we `cd` into directory? [duplicate]
I have multiple projects over various languages like JavaScript, Python. I wonder if Linux provides some functionality to trigger some actions automatically if we cd into a particular directory?
For ...
0
votes
1
answer
324
views
Add heredoc (<<) to end of alias within function call
I have an alias which is my psql connection string for a database, let's say the alias is this:
alias GQQ='psql "host=$host user=$redshift_uname dbname=$redshift_dbname port=$port pass word=$...
1
vote
3
answers
3k
views
How do I make an alias for a command with sudo
I want to add two aliases, so one executes a command when non sudo, and the other executes a command when sudo, like this:
alias v = 'nvim'
alias 'sudo v' = 'sudo -E nvim '
I also have set alias sudo=...
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,...
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 ...
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
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 ...
0
votes
1
answer
333
views
What is the best way for storing and versioning his aliases/functions/symlinks?
actually I have these lines (exemplary) in my .zshrc file:
. ${TOOLS_HOME}/cli/.cli_base
. ${TOOLS_HOME}/cli/.cli_functions
. ${TOOLS_HOME}/cli/.cli_symlinks
This works fine so far. My only problem ...
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 ...
0
votes
2
answers
922
views
Alias when not first word: `G='|grep'` then `command G grep-string`
I find myself typing | grep and | less a lot, and was wondering if there was any way to be able to do something like:
alias G='| grep -E' # egrep is deprecated
alias L='| less'
So I could do ...
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. ...
1
vote
1
answer
864
views
How can bash aliases be configured to handle spaces in directory names? [duplicate]
The alias below works well in zsh when spaces in directory names are \ escaped, but bash doesn't handle them properly. What changes would be required to make them work with bash properly.
dum() {
...
1
vote
1
answer
940
views
Zsh suffix alias alternative in bash
In zsh I can open any file with a special suffix or extension like .log or .txt with a program with typing its file name only
$ alias -s txt=nano
$ word.txt
That open the file word.txt with nano. ...
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 ...
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 ...
1
vote
2
answers
2k
views
How do you manage your bash/zsh Aliases?
How do you manage your bash/zsh Aliases?
Is there a tool to do this more easily and less "think of an alias -> open .zshrc-sourced-file -> edit -> close, reload .zshrc -> use alias"?
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 ...
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 ...
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 ...
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 (...