Questions tagged [alias]

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 at the command-line and avoid having to remember complex combinations of commands and options.

An alias is essentially nothing more than a keyboard shortcut, an abbreviation, a means of avoiding typing a long command sequence.

If, for example, we include alias lm="ls -l | more" in the ~/.bashrc file, then each lm typed at the command-line will automatically be replaced by a ls -l | more. This can save a great deal of typing at the command-line and avoid having to remember complex combinations of commands and options.

Setting alias rm="rm -i" (interactive mode delete) may save a good deal of grief, since it can prevent inadvertently deleting important files.

Further reading

In Bash, when to alias, when to script, and when to write a function?

How do I get bash completion for command aliases?

External references

894 questions
16
votes
1 answer

Multiples aliases for one command

I need to have multiple aliases for one command. I've done it like that: alias lwbc='$(npm bin)/webpack' alias lwpc=lwbc Is this a correct way?
10
votes
1 answer

Creating multiple temporary aliases

I am not a root user & I don't have access to the global alias file which has all the aliases created, but I want to create some aliases which remain active only for the session I am logged in. I use the command alias x='cd /parent/child' to create…
Web Nash
  • 2,283
6
votes
2 answers

Aliases interpretation

I have a few aliases in .bash_aliases. I defined c alias as follows, but it does not work as it should: ... alias cd='cd; ls -r --time=atime' alias c='cd' ... In .bashrc there is a line: alias ls='clear; ls --color=auto' Commnand c gives bad…
xralf
  • 15,415
4
votes
1 answer

Bashrc alias the SSH command in order to connect and directly cd to a defined path

I have an alias that connects to my development server: alias sshDev='ssh -p 22 username@ip_address' I'd like to be able to both connect and automatically switch to a new directory: cd ../my-favorite-directory Is there anyway to run both commands…
3
votes
1 answer

Prevent alias expansion when alias is passed as an argument

I have two aliases: alias rm='python my/rm/script.py ' alias docker='sudo docker ' The problem is that when running the statement $ docker rm ARGS the keyword rm is being expanded as alias and docker complains that 'python' is not a docker…
Firelord
  • 342
3
votes
1 answer

Create alias that can interact with arguments

My ultimate goal is to simplify routine task of compilation and run. Now I've following commands 1. g++ foo.cpp -o foo --std=c++11 2. chmod foo +x #this may be overkill 3. ./foo So, my question if this can be done like compile foo with alias or…
2
votes
2 answers

The alias does not work ?

I create an alias in ~/.cshrc like this alias bw "bjobs -w | awk '{print $7}'" but it doesn't work at $7. How do I fix this ?
1
vote
1 answer

How to execute alias right after sourcing it in a one liner?

I'm trying to write a one liner that sources aliases, then calls one of those newly sourced aliases. My one liner is basically: alias startEnv sourceAliasFile;runNewAlias Since I'm using csh, I can't make a function. When I run this, my source…
Malik
  • 11
0
votes
1 answer

tilde_expand: No such user .ssh

I have this weirdest error where a single IP address with ssh would immediately return an error arthur@arthur-laptop:~$ ssh 192.168.1.85 tilde_expand: No such user .ssh I feel like it's an issue with autocompletion or something similar. And I have…
0
votes
0 answers

How can I make uncommon symbols more accessible?

I am using Bash in Linux, inside Termius on a smartphone. I would like to make reaching for particular symbols as fast as possible, by customizing bash to interpret certain character sequences as those symbols. On a smartphone, maximum speed is…
0
votes
1 answer

Can we make aliases for the commands with parameters

I want to make alias for: rm -rf * => #rm -rf * rm * => #rm * When I type rm -rf *, I want it to be commented out and not take action. [Q] General question is can we make generate aliases for the commands with parameters?
alper
  • 469
0
votes
0 answers

How to alias `kj` to `kill -9 %?`(kill job)

I want use kj 1 for kill -9 %1 I try: alias kj='kill -9 %' but I can't use either kj1 or kj 1. It's there any way to do this?
0
votes
1 answer

How to put temporary aliases in a file?

I can put aliases in my .bashrc (or files called from it) and they then work in my shell. I can also then create other aliases at the command line, e.g. alias aaa='ls' and it works. aaa does an ls operation But if I put that alias definitions in…
0
votes
0 answers

Creating alias with single parameter used in multiple places

I am trying to create a simple alias for SSH-ing to a host, like the below: alias wpessh='ssh $1@$1.ssh.wpengine.net' I also tried using a function as suggested by other answers here: function wpessh { ssh "$1"@"$1".ssh.wpengine.net; } export -f…
wickywills
  • 2,093
0
votes
1 answer

safe way to add aliases for another user?

At work I have a personal account, but I'm doing development on a program which is run by a machine account. By "machine account" I just mean that it isn't tied to a person - it doesn't have any special sysadmin role, but it runs our batch jobs.…
Stephen
  • 149
1
2