An alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence. This can save a great deal of typing in the command-line and avoid having to remember complex combinations of commands and options. Use this tag for questions about using aliases with the bash shell.
Questions tagged [bash-alias]
82 questions
83
votes
3 answers
How to unalias a minus?
My morning coffee hadn't reached my brain yet when I forgot the quotes in:
alias grep="grep --color=always"
so instead I typed:
alias grep=grep --color=always
leaving me with:
--color=always
grep=grep
in my aliases.
When I try to cleanup the…
Requist
- 930
78
votes
9 answers
How can I use a Bash-like shell on Windows?
I use Linux and a Mac, and I'll be teaching some command line stuff soon.
What can I install on Windows to give me a terminal window most similar to a basic Mac/Linux Bash shell?
I would like to be able to define .bash_aliases as well if possible.
Michael Durrant
- 1,328
27
votes
3 answers
Is it possible to override the command line's built in "cd" command?
Just about every time I 'cd' to a different directory on my machine (in this case, running Mac OS X 10.6.7) via the command line (which is bash), I immediately type 'ls' to get the list of contents in that directory. I'm trying to figure out a way…
Alan W. Smith
- 455
23
votes
1 answer
Bash is slow to start because of this line in .bashrc. What could cause this?
My .bashrc file contains a line to this effect:
alias prog="/path/to/script.sh $(find $(pwd) -name prog)"
When I comment out this line, Bash starts almost instantly when I open a new terminal. With this line, there is a 4-5 second delay before my…
BBales
- 333
- 1
- 2
- 5
18
votes
4 answers
Unable to use scp with a bash alias
This code does not work:
scp ~/Desktop/favicon.ico nameOfBashAlias:/public_html/mySite/templates/blog/
The alias is:
alias nameOfBashAlias='ssh myUsername@11.11.11.111'
How do I solve this problem?
Edit
Is something similar to the following code…
Léo Léopold Hertz 준영
- 5,924
10
votes
2 answers
Alias does not "override" PATH entries?
The last line of my .bash_profile is:
alias cp=/usr/local/bin/gcp
However that is being squashed by the entry in my $PATH :
$which cp
/bin/cp
11:54:32/OCspark $type cp
cp is aliased to `/usr/local/bin/gcp'
I had thought that aliases override the…
WestCoastProjects
- 4,032
9
votes
2 answers
Creating an alias containing bash history expansion
I often forget to run a command with sudo, so I find myself often typing sudo !! immediately afterwards.
I tried aliasing this, but bash chokes on the !! part. Is there some way to represent this shortcut within an alias?
andrewdotnich
- 285
8
votes
1 answer
How to use alias inside another alias in ZSH?
Let's say I have the following alias definition in my ZSH config file:
alias myalias="cd /"
how can I use myalias inside another alias? ie:
alias myaliasone="myalias && cd /usr"
I have tried (with a real alias this one is a fake just for example…
ReynierPM
- 395
8
votes
6 answers
Creating alias for Trash
I am a newbie. I set an alias in .bashrc file as follow.
alias myrm='mv /home/user/Trash/*'
The purpose is that when I use myrm comment, for example $myrm foo, the file "foo" has to be moved to the Trash folder which is in my home folder…
phenomenon
- 215
- 4
- 7
8
votes
2 answers
Can I make bash stop parsing and validating a certain alias?
I'm using Fedora 25, and have added the following alias to my bash profile:
alias releasenotes="dnf updateinfo --refresh info `dnf check-update | cut -d '.' -f 1 | xargs` | less"
(I can't use straight-up dnf updateinfo info because of…
iLikeDirt
- 333
- 3
- 9
6
votes
1 answer
Using alias to echo backticks in bash
Apologies if this is answered elsewhere, I could not for the life of me find a solution to my particular case, which is a bit strange I admit. (Note: all the “Using” words in this post appear blue for some reason, but they shouldn’t be and I don’t…
Galen
- 163
5
votes
4 answers
Aliases in .bash_profile do not work
I have added some cd blah blah commands as alias in my .bash_login so as to ease changing directories.It was working fine .Suddenly though none of the aliases in there work .It says command not found .I have no clue as to why all of a sudden it…
Manish
- 239
5
votes
4 answers
Space in doskey/alias for windows?
I try to run Laravel's Artisan command inside the (docker) container by defining a doskey alias.
My idea was:
php artisan=docker-compose exec apache php artisan $1
However it does not allow me to use a space in the key. Any idea how to achieve…
Thomas
- 659
5
votes
1 answer
Windows 10 Ubuntu Bash: Aliases not working (: command not found)
I started the Ubuntu bash on Windows that was shipped with the Anniversary Update 1607. This bash sources the .bashrc file located at /home/phil which is the home directory of the Unix user, not the Windows user (this would be /mnt/c/Users/Philipp).…
user232846
4
votes
1 answer
Bash Alias to perform Alt+1?
Using Ubuntu I can create a terminal with two tabs:
gnome-terminal --tab --tab
However, by default it goes to the last created tab. Using Alt + 1 I can make it go to the first, but I want to avoid key presses.
I'd like to either create an alias to…
Armando