# Tag Info

58

You can press Ctrl-Alt-e to perform the readline function shell-expand-line which will do alias, history and word expansions. Note that on some keyboards Meta is not Alt. You might need to press Esc then Ctrl-e The functions alias-expand-line and history-and-alias-expand-line are not bound by default, but you can bind them by adding lines similar to the ...

55

The Bash documentation states "For almost every purpose, shell functions are preferred over aliases." Here is a shell function that replaces ls and causes output to be piped to more if the argument consists of (only) -la. ls() { if [[ $@ == "-la" ]]; then command ls -la | more else command ls "$@" fi } As a one-liner: ls() { ...

31

It is rather easy to setup permanent aliases in the Windows command prompt using the @DOSKEY command and HKCU\Software\Microsoft\Command Processor Autorun option. Quick step-by-step guide: Create a new batch file, call it Alias.bat. Copy/paste the text below. TIP: I recommend creating a C:\Bin folder for all your command line tools. Open the register ...

27

From the alias man page: The first word of each simple command, if unquoted, is checked to see if it has an alias. If so, that word is replaced by the text of the alias. The alias name and the replacement text may contain any valid shell input, including shell metacharacters, with the exception that the alias name may not contain `='. ...

20

Simply use the command alias which prints out all definitions in a format bash can read in again: $alias alias second='again' alias test='hello' So to recover, simply use$ alias > .bash_aliases

18

Just to be clear, I'm basing this on the assumption that you really do want http://local.example.com to load the literal web page http://localhost/path/to/example.com. In other words, this will only work for this machine. If, on the other hand, you're trying to serve web pages to the outside world using your Mac OS X machine, then that's a different ...

16

This is only possible if the two DHCP clients use different MAC addresses. Which means they cannot run both on the same physical network interface, which has a single MAC address. The solution is Linux's virtual MAC-VLAN network interfaces. MAC-VLAN interfaces are virtual network interfaces backed by a physical interface, but using with a different MAC ...

15

Vim 'ignores' your aliases because your shell is not in a 'mood' to parse your .bash_profile/.bashrc (you did not specify, where your aliases are defined) because it is not started as a login/interactive shell (read here to find out more about what is read when and for what reason). So, you have several options: Put the code you use in your pdflatex alias ...

14

You can remove an alias simply using: $unalias gcm 10 A slightly improved approach taken from Dennis' answer: function ls() { case$* in -la* ) shift 1; command ls -la "$@" | more ;; * ) command ls "$@" ;; esac } Or the one-liner: function ls() { case $* in -la* ) shift 1; command ls -la "$@" | more ;; * ) command ls "$@" ;; esac } This allows for further options/arguments to be appended after ... 10 Just redirect the output. unalias rm mv cp >/dev/null 2>/dev/null 10 Although this question is over a year old and already answered, the following solution is simpler and avoids editing the registry: In Console2, go to Edit > Settings. Change the "Shell:" field to the following: C:\Windows\system32\cmd.exe /K "C:\Path\to\aliases.cmd" Now restart Console2 and you're done. To possibly save you some time, here's a simple ... 10 Aliases are not inherited. That's why they are traditionally set in bashrc and not profile. Source your script.sh from your .bashrc or the system-wide one instead. 10 When you use alias${alias_line}, the variable is broken up at spaces, ignoring quoting rules. There are two ways you could fix it: Remove all quoting from the alias file: ll=ls -lart psu=ps -fu $USER and put the variable itself in quotes: alias "$alias_line" This works because in bash, ll="ls -lart" and "ll=ls -lart" are exactly equivalent. ...

10

You can probably create an alias for that. Assuming you are using Bash, create a .bash_aliases file in your Home directory, if it already doesn't exist. Then, add a line with the following to the file: alias apt='sudo apt-get' Now close the shell and reopen it again. Now you can install any new package with the syntax apt install <package-name>. ...

9

Put a backslash before the first character. $alias ls="echo foo"$ ls foo $\ls bin Desktop Documents ... 9 Aliases have no parameters, try function instead cd() { builtin cd "$1" ; ls ; }

9

Did you source your .bashrc file after you changed it? Try: . ~/.bashrc Then your shell should see the changes. Alternatively, you can terminate and restart your shell.

9

You can't. By running your script you execute a new shell. Aliases will not be seen by the parent process. The only way as pointed out is using source so that the current shell processes your script file (without starting a new process).

8

You should put it under: /etc/bash.bashrc to be available to all users.

8

Your mac is probably using bash as shell, so you need to type alias la='ls -la' instead of alias la 'ls -la'

8

I think it needs to be: alias la='ls -la' (note there are no spaces around the equal sign.)

8

Here is the source of the error message: $git log %ad fatal: ambiguous argument '%ad': unknown revision or path not in the working tree. Use '--' to separate paths from revisions You will get the same error message from the following two commands:$ git log --pretty=format:%h %ad | %s%d [%an] --graph --date=short $git log --pretty=format:\"%h %ad | %s%... 8 From man bash: For almost every purpose, aliases are superseded by shell functions. So make it a shell function. function cmakerel { if expr match "$PWD" '.*bld.*' >/dev/null ; then cmake -D.... else echo "Wrong directory!" fi } It's a regular expression you can adjust to your needs.

7

This is what your PATH environment variable is for. Arrange your PATH environment variable so that both locations are on the path, AND in the order you want them to to be checked. So in your example, /usr/local/bin should be earlier in the PATH than /usr/local/bin/scripts. Most systems will probably have /usr/local/bin already in the system path, so you'...

7

It is possible to have separate identities like this. If using Lion's Mail.app, open ~/Library/Mail/V2/MailData/Accounts.plist in a property list editor (I used Xcode's built-in one). Be sure to close Mail first and make a backup of the plist file. Under MailAccounts there are a few Item dictionaries, from 0 to 2 in my case. Expand the one that contains ...

7

1) unalias dog 2) This will remove the lastmost directory from your path: PATH=${PATH%:*}. Repeat it as needed for however many bad entries you've got. 7 It'd be easier to make a function: cdd () { cd$1 ls } Of course, you can name the function whatever you like. Put it in your .bashrc or .profile or whatever it is on your system.

7

Console2 is only a wrapper around hidden Win32 console windows and does not provide extended line editing functionality. You can create aliases in Win32 consoles: doskey d=dir $* Unlike Unix sh, you have to explicitly specify$* to append given arguments (ex. d C:\). You can also use \$T to separate commands. Also unlike Unix, aliases are implemented at ...

7

What you did should work. Troubleshooting: Are you under root? Did ln command actually succeed? Verify with ls -l /usr/bin/roo which should list the newly created link. If the link is not there, add "sudo " before ln to execute it as root (sudo will prompt for root's password): sudo ln -s /path/roo.sh /usr/bin/roo Sometimes bash remembers where a ...

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