The alias built-in in shells, used to define shortcuts for frequently used commands.

learn more… | top users | synonyms

1
vote
0answers
497 views

Dynamic search and replace in Ksh

Machines at work follow a constant naming pattern: host[domain]_[id] where [domain] is either "d" for dev machines and "p" for production machines, and [id] is a 2-digit string that is different for ...
1
vote
1answer
265 views

Error creating an alias for the find command [duplicate]

Possible Duplicate: How to pass parameter to alias? I am trying to shorten the find command, but getting an error: $ alias f='find . -name $1 -print' $ f JobConf.java find: paths must ...
7
votes
6answers
5k views

Show only hidden files (dot files) in ls alias

I'm using the command ls -a | grep '^\.' for showing only the hidden files. I added the line alias hidden='ls -a | grep '^\.'' # show only hidden files to .bash_aliases file but this does not ...
6
votes
1answer
2k views

Alias a command to run in the background

I'd like a keyboard shortcut to work as so: > e foo.txt to expand as > emacs foo.txt & It's simple to use alias e=emacs, but how do I insert the & after the filename? I realize it ...
6
votes
2answers
486 views

What commands have -h human readable option, and how can I enable it by default w/env variable?

I'm tired of using aliases or typing -h. I want human readable output 24/7. Is there a way to enable it all the time for all commands that offer it?
6
votes
2answers
176 views

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 ...
5
votes
4answers
143 views

Change command-line “environment” to programs command

In a console, is it possible to change into a commands "environment"? To explain, I take "git" as an example. While programming and using a git repository, I change to the repos path and then do many ...
4
votes
2answers
273 views

Combine two commands in .bash_profile

In my .bash_profile file, I'd like to setup a single command alias that is two commands that execute one after another. The first command takes an argument from the command line and the second is ...
2
votes
2answers
774 views

creating simple command for sudo apt-get install?

I need to run these commands very often: sudo apt-get install <package> sudo apt-get remove <package> Can I make it simple like: install <package> remove <package> I ...
1
vote
1answer
999 views

/etc/hosts in debian resets itself on reboot

I've been having a problem where when our vps provider decides to restart the server (running Debian 5.0.8), the server fails to remember changes to /etc/hosts. All I need is an database alias that ...
7
votes
1answer
5k views

How to reset a shell environment?

This issue has been bugging me for a while, and although I've taught I've found my answer through EnvWatcher, unfortunately it only works on Bash. And I use zsh. I would like to replicate the things ...
1
vote
2answers
235 views

How can I add a space automatically after every command I type in bash?

Due to some unknown reason I am not able to edit/delete the last character of any bash command from the bash history i.e. when I access last bash command using 'up' arrow I cannot change or delete the ...
3
votes
1answer
406 views

Git - remove deleted files

I'm using this simple git alias rmdel = "!git rm $(git ls-files -d)" meant "remove deleted", i.e. to remove from the staging area all files deleted from the file system. It works fine except ...
3
votes
1answer
183 views

postfix default alias used even when I have other aliases

I tried adding a rule to /etc/aliases which would send a message to /dev/null if it was sent to a particular alias: fooname: /dev/null I have postfix set up with a default address for a particular ...
2
votes
2answers
331 views

My alias parser works on the command line but not from a script

I'm trying to create a simple script that will dump all my aliases into a file that bash can load when it starts up, while making sure the alias of - to popd works properly: alias -p | sed 's/alias ...
4
votes
1answer
252 views

Preventing use of `cd ..` in bash?

I have set up an alias in my .bashrc as follows: alias u='cd ..' All is well in my world... until I type cd .. and cringe that I did not use my incredible new alias. In fact, with this particular ...
7
votes
2answers
2k views

How do I temporarily bypass an alias in tcsh?

I am using tcsh. bash and zsh and other suggestions won't help here. I have several aliases that are named the same thing as another command, so if I did unalias it, typing the same thing would now ...
8
votes
4answers
301 views

Do you prefer bash scripts or aliases for shortcuts?

I have a ~/bin directory (which is on my PATH) where I store a lot of little 1 or 2 line scripts. Some of them just cd into a directory and run a command on a file, like vim or something. But I also ...
6
votes
1answer
293 views

Does one alias affect another alias?

I don't have many aliases set up in my .bash_aliases file just yet. Only recently have I discovered how useful they can be. I can see myself getting quite hooked on aliases so before the file gets ...
7
votes
3answers
521 views

Forcing an 'added' alias to every command

Is it possible to forcibly add a timing alias (for lack of a better way to phrase it) to every command in bash? For example, I would like to have a specific user who whenever a command is run, it is ...
10
votes
2answers
379 views

How to use - as alias?

When I was using openSUSE 11.3, it came with several aliases already set up. Two that I used a lot were + for pushd . and - for popd. Now on Debian, I can't figure out how to create the second one. ...
1
vote
1answer
160 views

Aliases for programs in /sbin/

I have a weird problem, unfortuantely I don't know what I did to cause this, since I tried out lots of stuff on my Linux (Archlinux, 2.6.38 kernel). The problem is: My shell is not finding programs in ...
5
votes
1answer
4k views

How do I get which to show aliases? [duplicate]

Possible Duplicate: How to use which on an aliased command? I'm used to working on systems where which would list aliases, so e.g. if I have an alias like this: alias ...
34
votes
3answers
3k views

How to use `which` on an aliased command?

Like most users, I have a bunch of aliases set up to give a default set of flags for frequently used programs. For instance, alias vim='vim -X' alias grep='grep -E' alias ls='ls -G' The problem is ...
1
vote
3answers
2k views

alias or bash function does not work

When I create alias wd='ps -ef | grep java | awk {'print $2 " " $9'} | egrep "(A|B|C|D)"' or function wd () { ps -ef | grep java | awk '{print $2}' ... } in my .bashrc file, I get errors. ...
1
vote
3answers
889 views

A problem with find and grep

I have defined the following alias in ~/.bashrc: alias fg='find . -name $1 | xargs grep --color $2' in order to write fg "*.txt" " my_text " and find all file that have extension .txt and ...
4
votes
1answer
83 views

Remove alias from current session

How to remove a alias from current session without closing that session?
6
votes
2answers
6k views

Can I make scripts use aliases instead of commands?

I have an alias for a command (I'm setting up a Python development environment) alias python=~/virtualenv/bin/python so that I can run ~/virtualenv/bin/python by just typing python. Now in my ...
83
votes
13answers
29k views

How to have tail -f show colored output

I'd like to be able to tail the output of a server log file that has messages like: INFO SEVERE etc, and if it's SEVERE, show the line in red; if it's INFO, in green. What kind of alias can I ...
2
votes
2answers
263 views

Specify an alias as preferred editor in rc files (like .cvsrc)?

I have in my .cvsrc: cvs -q -e vim I want to create an alias (like my-vim or something like that): alias my-vim="vim -S ~/myscript.vim" And do cvs -q -e my-vim Unfortunately, this doesn't ...
9
votes
3answers
2k views

Is there a 'rc' configuration file for grep/egrep? (~/.egreprc?)

I usually do some grep when developing, and there are some extensions that I always don't want to look for (like *.pyc). Is it possible to create a ~/.egreprc or something like that, and put some ...
4
votes
2answers
2k views

Escaping quotes in zsh alias

Following on from this question about stripping newlines out of text, I want to turn this into a zsh alias as follows: alias striplines=' awk " /^$/ {print \"\n\"; } /./ {printf( \" %s \",$0);}"' ...
2
votes
3answers
439 views

su and aliases confusion

I create an alias as my current user in the bash shell, which I can see using the alias command. When I switch user without the -, i.e. su testuser, the alias is not carried into the new user's ...
3
votes
2answers
720 views

zsh alias expansion

Is it possible to configure zsh to expand global aliases during tab completion? For example, I have the common aliases: alias -g '...'='../..' alias -g '....'='../../..' but when I type for ...
2
votes
3answers
482 views

How can I turn the behavior of `gedit sOmEtHiNg & disown` into the default behavior when calling gedit from the command line?

When I gedit files from the command line, it's always locking the terminal, and I'm tired of explicitly commanding a detached process for it. I tried to alias gedit as something like gedit $* & ...
14
votes
5answers
5k views

What is the difference between ls and l?

I accidentally typed l instead of ls today and found that the command still printed a list of the files in my current directory. Trying l --help brings up the help file for ls suggesting that l is ...
17
votes
2answers
3k views

aliasing cd to pushd - is it a good idea?

Is it a good idea to use the following alias: cd() { pushd $1; } in bash? I think this would be very useful, since I can then use a series of popds instead of just a cd - once. Is there any ...
9
votes
2answers
694 views

Change directory without typing cd?

Is it possible to make bash change directory in command line simply by typing that directory without any commands like cd? For example is it possible instead of writing this: $ cd /tmp I just want ...
17
votes
1answer
3k views

How do I get bash completion for command aliases?

I am looking to get tab-completion on my command line aliases, for example, say I defined the following alias : alias apt-inst='sudo aptitude install' Is there a way to get the completions ...
18
votes
1answer
2k views

Aliases vs functions vs scripts

This site says, "Shell functions are faster [than aliases]. Aliases are looked up after functions and thus resolving is slower. While aliases are easier to understand, shell functions are preferred ...
24
votes
3answers
6k views

How to pass parameters to an alias?

For bash script, I can use "$@" to access arguments. What's the equivalent when I use an alias?
13
votes
3answers
2k 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 ...
3
votes
2answers
832 views

How can I simulate keyboard shortcuts in a bash alias?

For example, one of my bash aliases is this alias p='clear;ls -lt;pwd;' clear also clears the history which I don't want. I just want to clear the screen momentarily. Ctrl+L however does exactly ...
31
votes
6answers
22k views

Why doesn't my Bash script recognize aliases?

In my ~/.bashrc file reside two definitions: commandA, which is an alias to a longer path commandB, which is an alias to a Bash script I want to process the same file with these two commands, so I ...