Tag Info

Hot answers tagged

53

To create an alias permanently add the alias to your .bashrc file gedit ~/.bashrc And then add your alias at the bottom. Now execute . ~/.bashrc in your terminal (there should be a gap between the . and ~/.bashrc. Now you can check your alias.


53

Add the following line to your ~/.bashrc: alias sudo='sudo ' From the bash manual: Aliases allow a string to be substituted for a word when it is used as the first word of a simple command. The shell maintains a list of aliases that may be set and unset with the alias and unalias builtin commands. The first word of each simple command, if ...


44

There are lot of ways to create alias . The most used ways are : 1) . Add aliases directly in your ~/.bashrc file For example. append these line to ~/.bashrc file alias ll='ls -l' alias rm='rm -i' Next time when you type rm the rm -i command will be executed. 2). The second method lets you make a separate aliases file, so you won't have to put them ...


35

The type builtin is useful for this. It will not only tell you about aliases, but also functions, builtins, keywords and external commands. $ type ls ls is aliased to `ls --color=auto' $ type rm rm is /bin/rm $ type cd cd is a shell builtin $ type psgrep psgrep is a function psgrep () { ps -ef | { read -r; echo "$REPLY"; grep ...


30

In Ubuntu, the default .bashrc skeleton file looks for a .bash_aliases file in your home directory when you log in and sources it. So if you just create a .bash_aliases file and put any aliases you want in it, it should be sourced automatically when you open a new bash shell (no need to log out of desktop and back in, just open a new terminal). Here's the ...


25

From Bash Tips and Tricks: 'cd' with style: Finally, I want to show you how to write your own custom replacement for the 'cd' command. Do you find yourself always typing the same thing upon changing into a directory? You probably at least list the files there every time, perhaps so much that your hands automatically type 'ls' after every 'cd'. ...


19

Just type alias while at the Shell prompt. It should output a list of all currently-active aliases. Or, you can type alias [command] to see what a specific alias is aliased to, as an example, if you wanted to find out what the ls alias was aliased to, you could do alias ls.


16

If you want to check something in bash, use type and man. In your case you want to know what is . $ type . . is a shell builtin shell builtin means that . is inside bash shell. You can find information about shell builtins in bash manual page. There is a big section SHELL BUILTIN COMMANDS $ man bash SHELL BUILTIN COMMANDS Unless otherwise ...


15

While the other answers offer a good workaround for your problem, to answer your question, the right way to use an alias inside a .desktop file is, in your case: Exec=bash -ic "midos" That's because aliases from ~/.bashrc file will work only in a bash interactive shell (-i option is used in this case to start bash interactive). If another user wants to ...


15

Sure, although I have never tried it as an alias but it should work: sudo apt-get update && sudo apt-get -y upgrade


15

Use a function instead of an alias: cs() { cd "$1" && ls; }


15

In your shell script use the full path rather then an alias. In your shell script, set the alias, different syntax petsc='/home/your_user/petsc-3.2-p6/petsc-arch/bin/mpiexec` $petsc myexecutable Use a function in your script. Probably better if petsc is complex function petsc () { command 1 command 2 } petsc myexecutable Source your aliases ...


14

I really like Ctrl+Alt+E as I learned from this answer. It "expands" the currently typed command line, meaning it performs alias expansion (amongst other things). What does that mean? It turns any alias, that might be currently written on the command line, into what the alias stands for. For example, if I type: $ ls and then press Ctrl+Alt+E, it is ...


14

With most commands, you can pass -- as an argument, and all subsequent arguments are treated as operands and not options, even if they begin with a dash. The alias builtin in bash recognizes --. alias -- -='cd -'


13

Alias are deprecated in favor of shell functions. From bash manual page: For almost every purpose, aliases are superseded by shell functions. To create a function, and export it to subshells, put the following in your ~/.bashrc: petsc() { ~/petsc-3.2-p6/petsc-arch/bin/mpiexec "$@" } export -f petsc Then you can freely call your command from your ...


13

The command to remove an alias is unalias so.... unalias -a gs Manual: NAME unalias - remove alias definitions SYNOPSIS unalias alias-name... unalias -a DESCRIPTION The unalias utility shall remove the definition for each alias name specified. See Alias Substitution . The aliases shall be removed from the current ...


11

You can use the builtin command in bash : function cd() { new_directory="$*"; if [ $# -eq 0 ]; then new_directory=${HOME}; fi; builtin cd "${new_directory}" && ls }


10

You can do it, but only if your directory names don't contain several consecutive spaces, and only if they contain no shell special character other than spaces. cd () { builtin cd "$*"; } In practice, use completion: type cd My then press Tab. Bash will insert backslashes before special characters.


9

Here are some that I like: #Opens current directory in a file explorer alias explore='nautilus .' #Opens current directory in a file explorer with super user privileges alias suexplore='sudo nautilus .' #Opens current directory in Ubuntu's Disk Usage Analyzer GUI with super user privileges in the background alias analyze='gksudo baobab . &' #Opens a ...


8

You can set this option in one f the mplayer option files, this will then be the default behaviour. For system wide change /etc/mplayer/mpplayer.conf of just for that user create ~/.mplayer/mplayer.conf and put it in there. Adding this to ~/.mplayer/mplayer.conf works: msglevel=all=0


8

Actually both ls and l are equal raja@badfox:~/Pictures$ l des.png Screenshot from 2012-09-22 19:37:03.png Screenshot from 2012-09-22 19:37:11.png Screenshot from 2012-09-22 19:37:12.png Untitled.png raja@badfox:~/Pictures$ ls des.png Screenshot from 2012-09-22 19:37:03.png Screenshot from 2012-09-22 19:37:11.png Screenshot from 2012-09-22 19:37:12.png ...


8

aliases do not support the positional parameters so you need to create a function (in ~/.profile) and alias that function. function grepMe(){ grep "$1" ~/myfile } and then alias it.. alias grepAlias="grepMe"


7

When using this command as an alias, $0 is no more protected by the single quotes and then converted to your shell name which happen to be an unset variable name, leading to the empty lines. One way to protect $0 from shell expansion would be to use something like: alias F="find -type f -size +1k -exec ls -gGsSh1 {} + | awk 'NR<=10 {print \\$0}'" As ...


7

Don't bother around with aliases for more complicated stuff, use a shell function instead: function cccc() { find {,/usr}/{,s}bin -printf '%f\0' | xargs -0 whatis | sort | less } See man bash for the justification: The rules concerning the definition and use of aliases are somewhat confusing. Bash always reads at least one complete line of ...


7

The tilde (~) has a special meaning in bash, is an expansion of bash and takes the value of $HOME environment variable. Read Tilde Expansion section from GNU Bash Reference Manual to understant how it wors. So, I think that what you want to accomplish is something similar to: myuser@ubuntu:~$ pushd -n "/home/myuser/Applications/Custom/Java" ~ ...


7

Create a file called something like runthisstuff In this file, stick a bunch of commands: alias doc='cd ~/Documents/' alias ps='ps aux' date Now run the file like so: $ source runthisstuff It will print the date, and you can now use the aliases. The date command is just to show you that you can pretty much stick anything you want in there, and it will ...


7

alias new_name='old command' For creating a permanent alias you've to edit the .bashrc file in youre home dir. More info here More .bashrc files here


7

With the first method you are not creating an alias, you are creating a symlink. Symlinks are short for symbolic links: Symbolic links are files that act as pointers to other files. [...] A symbolic link is a special type of file whose contents are a string that is the pathname another file, the file to which the link refers. In other ...


7

Creating an alias To add an alias type the following in terminal,it will work until you close your terminal. alias kt='killall gnome-panel' To add this alias permanently you have to add the above command into .bashrc file gedit ~/.bashrc Add the first command at the end of your .bashrc file, To refresh your .bashrc file type the following ...


6

The problem is that you are trying to execute a non executable file: You can check this with: ls -la ~/.bashrc -rw-r--r-- 1 username username 3596 2010-08-05 17:17 /home/pt001424/.bashrc Note there is no "x - executable" letter on the first column (file permissions). Profile files are not executable files, instead of executing them you load them with: ...



Only top voted, non community-wiki answers of a minimum length are eligible