Hot answers tagged

30

All you need to do is type alias at the prompt and any active aliases will be listed. Aliases are usually loaded at initialization of your shell so look in .bash_profile or .bashrc in your home directory. unalias will only work for your current session. Unless you find where it is defined and loaded, it will be loaded again when you start a new Terminal ...


24

The quote marks are preventing ~ from being expanded to your home folder, so you need to either quote just the part with the space in it: ln -s ~/"Foo Bar/" Foo Note: exactly how much is quoted doesn't matter, as long as the space is in the quoted portion and the ~ isn't. ~/Foo" "Bar/, ~"/Foo Bar/", ~/Fo"o B"ar/ etc are all equivalent. You could also use ...


14

An alias contains two pieces of information: a unique identifier of the file it links to, and the path and file name of the file it links to. If you rename or move a file, and then create a new file with the path and file name that the file originally had, then any alias that linked to the original file now links to the new file. However, if you rename or ...


13

You have to press cmd + alt while dragging


11

If you use bash, add the alias commands to ~/.bashrc and save a file like this as ~/.bash_profile: . ~/.bashrc When bash is invoked as an interactive non-login shell, it reads .bashrc but not .bash_profile. When bash is it is invoked as an interactive login shell, it reads .bash_profile but not .bashrc. Terminal and iTerm open new shells as login shells ...


9

In short you are putting your aliases in the wrong file .bashrc, that is why you need to keep running source to get the aliases working in any new login terminal instances. By default, Terminal starts the shell via /usr/bin/login, which makes the shell a login shell. On every platform (not just Mac OS X) bash does not use .bashrc for login shells ...


8

You can create soft links (a.k.a. symbolic links or symlinks) from the terminal, the same way as in any other Unix system. I'm not familiar with Dropbox so I'll make up an example assuming that there is a folder Dropbox in your home directory: cd ~ ln -s ~/Dropbox/aFolder Desktop/aFolder Note that ln takes the link to create as its second argument; think ...


8

Click any file or folder, press and hold down the ⌘ Command + ⌥ Option keys, and then drag the file or folder while continuing to hold down the ⌘ Command + ⌥ Option keys. An alias appears where you release the mouse button.


8

Let's try a few experiments and look at a few things. In the Terminal go to your home directory and create a directory. cd ~ mkdir test cd test Now create a file we can be sure about echo "We all loved Steve" > file.txt ls -l@ Try a hard link :- /usr/bin/ln file.txt hard.txt Then try a symbolic link :- /usr/bin/ln -s file.txt symbolic.txt ...


7

mkalias is a binary available in a set of tools here. It can also be installed via Homebrew with brew install osxutils. This is a SH shell script that calls AppleScript to create an alias. I'm including the shell script here for future reference incase it goes missing from the nets. #!/bin/sh # make_alias # This script takes two command-line arguments: # ...


7

You can't pass arguments to aliases. Aliases are just text substitutions without further logic. But you can use shell functions to achieve the same result: function pman() { if [ -x /usr/bin/open ]; then man -t "$1" | open -f -a Preview else man "$1" fi } The if-then-else part is there just to make sure it also works on ...


6

Try this on Terminal: cd ~/Desktop ln -s ~/Library/path/to/folder


5

It's possible to do it in one line of Terminal. Let's say you want to alias to the file "/Users/me/Library/Preferences/org.herf.Flux.plist". osascript -e 'tell application "Finder"' -e 'make new alias to file (posix file "/Users/me/Library/Preferences/org.herf.Flux.plist") at desktop' -e 'end tell' You should replace to file with to folder if you have a ...


5

For any app you want to add to your dock as a shortcut, the process is as follows: Launch the application. The application's icon will appear in the dock. Right click the application's icon in the dock. Go to "Options". Select "Keep in Dock". Now the application's icon will remain in the dock as a shortcut when you quit the application.


5

No - aliases are a combination of a sym link pointing to a place as well as a unique file ID to track that file if it moves so the alias won't be broken if the file still resides on the original volume. (the file ID changes across volumes and an alias will only remain valid if the relative path is correct if and when the file ID half is broken by a ...


5

Use absolute paths for the jar file: alias dsim='java -jar /path/to/dsim.jar'


4

I keep aliases in ~/.bash_profile. Terminal and iTerm 2 open new shells as login shells by default. When bash is invoked as an interactive login shell, it reads ~/.bash_profile but not ~/.bashrc. The terminal emulators on other platforms often open new shells as non-login shells, so for example bash reads ~/.bashrc but not ~/.bash_profile. OS X users often ...


4

You can always put if [ -n "$BASH_VERSION" ] && [ -f $HOME/.bashrc ];then source $HOME/.bashrc fi into the file ~/.profile or ~/.bash_profile on mac I think. Oooor, you could just put your stuff in .profile or .bash_profile.


4

It seems like your bash shell is looking for .profile instead of .bashrc . What you can do is make a symbolic link: ln -s ~/.bashrc ~/.profile and restart your session (close, reopen Terminal). Any future bash setting updates can be made to .profile or .bashrc.


4

It doesn't work because the cd is executed on your local machine when the ssh does terminate. Here is the way to do it: alias appl="ssh 9@lon.orb.com 'cd /opt/tomcat/instances ; exec ${SHELL} -i'"


4

Since Lion, in addition to storing Retina icons, it seems that an alias stores its many different sizes of icons in both the data and the resource fork (the xattr com.apple.ResourceFork). Possibly in a move away from Resource forks, while still supporting previous OSes (for now). The alias I just created contained the follow formats: is32, s8mk, ic11, il32, ...


4

The default ls provided with OSX comes from BSD and won't allow you to do what you want. Using CoreUtils ls (installed with macport it's available with the gls command) You'll get your colors using --color=always: ls -l --color=always | awk ' { k=0; for (i=0;i<=8;i++) k+=((substr($1,i+2,1)~/[rwx]/)*2^(8-i)); if (k) printf("%0o ",k); ...


4

Hold down cmd and option when dragging.


4

It works on 10.8.2 without creating an alias. You can drag the shared folder to the sidebar. It will auto mount after you have disconnected.


4

To find aliases with mdfind, in a Terminal: mdfind kMDItemKind="Alias" This will print a list of aliases with the fully qualified pathname. Note: These are aliases created in Finder, not symbolic links created with the ln command from a Terminal or script. To use find to find symbolic links created by, as an example, ln have a look at: man find ...


3

I haven't tested the answer by @klanomath, but there used to be a Python library to get the target of an alias, but Carbon support was removed from the Apple frameworks. It can be done in Objective C see http://stackoverflow.com/a/21151368/838253. The best bet is to use symlinks, but unfortunately Finder does not allow you to create these. I have written ...


3

Open a new Terminal window and go to your home directory (just type cd and press Enter). After that, type ls .bash* and also ls .profile (please note each of those file names starts with a dot). If you have those files (and you should have at least the .profile one) then you need to edit them and add your aliases to them. I use VI (or VIM) to edit those ...


3

Symlinks are a Unix concept. They are special files that point to other files, so that, in many cases, accessing the symlink (for instance if it points to a shell script) really access the underlying file (running the script). Aliases are a Mac concept (though OS/2 had something similar, I forget what it was called). As far as I can tell aliases can be ...


3

I'm not sure I understand your question. The -bash: prefix you see is simply bash's way of identifying itself as the source of the error message. In this case you entered cdp which is neither an external nor internal shell command nor was it defined as an alias or function. While in a (bash) terminal, you can simply type exit to leave the terminal and ...


3

You should have a look in /etc/profile or ~/.profile or ~/.bash_profile or ~/.bashrc Which are plausible startup files for your shell (that I assumed is bash).



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