# Tag Info

37

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 ...

28

ls() { if [[ $@ == "-la" ]]; then command ls -la | more; else command ls "$@"; fi; }

28

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 ...

19

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

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 ...

15

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 `='. ...

14

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 ...

10

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 ...

9

Put a backslash before the first character. $alias ls="echo foo"$ ls foo $\ls bin Desktop Documents ... 9 Just redirect the output. unalias rm mv cp >/dev/null 2>/dev/null 9 Aliases have no parameters, try function instead cd() { builtin cd "$1" ; ls ; }

8

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>. ...

7

You need the ~/.ssh/config file ForwardX11 or ForwardX11Trusted options. Specifically, if you want to add -X to every invocation of ssh, put something like this in your config file: ForwardX11 yes If you want to use if only for certain hosts, you need to set up a host specification for each host: Host <hostname> ForwardX11 yes Check out the ...

7

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 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

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 ...

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 Your mac is probably using bash as shell, so you need to type alias la='ls -la' instead of alias la 'ls -la' 7 I think it needs to be: alias la='ls -la' (note there are no spaces around the equal sign.) 7 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 ... 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 ... 6 For your case, network is 192.168.1.0, which means your ip address is in the network range, 192.168.1.0 to 192.168.1.255 You can always get your network base address easily by doing ip & mask, where & is logical AND. 6 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 ... 6 The second alias command will redefine the alias for "ls". You can double check by running the alias command with no arguments, to see which aliases are defined. 6 Open AppleScript Editor. Paste in the following code: tell application "Finder" to shut down Click File » Save, save it to the Desktop, selecting File Format: Application. If you've saved it as the correct format, the icon should look like this: 6 You can't configure that. But you could add a rule to delete messages you receive from yourself (or move them to another folder). 6 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 | ...

6

Use the following: alias -- -='cd -' -- is often used (especially with Gnu programs) to stop parsing the following arguments as options. That's also how you can e.g. rm files whose names start with -.

6

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.

6

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 ...

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