16
votes
Creating aliases for iTerm 2 that work during ssh
If you use oh-my-zsh, you will want to place those in ~/.zshrc
vi ~/.zshrc
.
.
.
# Example aliases
# alias zshconfig="mate ~/.zshrc"
# alias ohmyzsh="mate ~/.oh-my-zsh"
alias work="cd ~/Lucas/local-...
10
votes
Link command in terminal vs ln vs symbolic link (ln -s) differences between them?
On macOS, both executables have the same inode number, so technically they are the same.
$ ls -il /bin/{link,ln}
1152921500312524105 -rwxr-xr-x 2 root wheel 101968 Mar 21 07:13 /bin/link*
...
9
votes
Accepted
symbolic link vs. alias
Aliases store two pieces of information about the destination file - both the location and a file identifier. Symbolic links only store the other location. For that reason, if you move a file, Aliases ...
9
votes
Accepted
difference ZSH and BASH for $RANDOM?
bash starts array indexes at 0, zsh at 1.
One slightly strange-looking way to overcome this is
server_list=(HPC1 HPC2)
alias HPC='ssh -l username ${server_list[(($RANDOM % 2 - 2))]}'
This puts the ...
8
votes
Accepted
How do I make aliases hidden in macOS?
To change the file flag of a symbolic link, or a Finder alias, rather than its associated file, use the -h option:
$ chflags -h hidden file
To unhide a file that has the hidden flag set, use:
$ ...
7
votes
Accepted
How to create an Alias with a Variable inside?
You can't use alias for arbitrary substitutions. You can use a function instead.
function gre() {
grep -r "$@" .
}
grg♦
- 206k
7
votes
Turn Bluetooth On & Off via Terminal
Blueutil, a command-line utility for macOS that lets us turn Bluetooth on and off with one command!
Start by installing blueutil with HomeBrew:
brew install blueutil
The -p flag is a switch for ...
6
votes
Run lolcat after each command?
UPDATE
I put my implementation here with install instructions:
https://github.com/dosentmatter/rainbow-bash-prompt
It uses the C implementation of lolcat but I modified it a little to make it ...
6
votes
Accepted
How to use AppleScript in a bash script to create an alias for an app?
osascript will run AppleScript code in your shell. This example uses a HEREDOC to present the code to osascript.
/usr/bin/osascript <<'EOF'
tell application "Finder"
set myapp to POSIX file ...
6
votes
Create auto alias of every folder in a specific folder in bash_profile or bash_alias
It might be easier to add ~/Developer to CDPATH (works in both bash and zsh) and then use cd fancyproject to change to ~/Developer/fancyproject.
But if you want to go with aliases, and assuming you ...
5
votes
Accepted
How do you manage your zsh aliases?
Here's what I choose as a solution. I found this helps keep my initial .zshrc file free of clutter.
Place the aliases in their own file, ie: .zsh_aliases. You can also create a file for other things, ...
5
votes
Accepted
Limitations of iCloud+ own domain
I would plan that you lose all aliases you don’t assign and have strictly three aliases per user for a total of 15 distinct mail addresses.
https://support.apple.com/guide/icloud/add-a-custom-domain-...
5
votes
Accepted
How to use input variable in .zshrc alias?
From what I found, it is easier to use a shell function. You can simply define a function where $1 refers to the first argument given:
function mrc() { php artisan make:controller "$1" --...
5
votes
Accepted
Where can I find the alias file in macOS
Those two alias definitions are actually built-in to alias itself, which in turn is just a zsh built-in. So you would find those aliases buried within the zsh binary in /bin/zsh.
In source code form, ...
4
votes
How to use AppleScript in a bash script to create an alias for an app?
Why not skip the Applescript and just create a symbolic link in bash? It behaves exactly like an alias on the desktop except now you can work with it in bash. See this answer for a breakdown of ...
4
votes
What's the difference between alias and link?
I'm quite confused by sentinel's anwser on create a new file with the path and filename that the file originally had. Also it's abrupt, why you want to do that?
Well, if you understand why and how ...
4
votes
Alias - 'Show Original' in new tab
I looked around and found an applescript (which can be turned into a shortcut) that does just want you want. Unfortunately, it's not super simple like it should be. It's better than nothing though, ...
4
votes
Alias - 'Show Original' in new tab
A much shorter and cleaner solution without UI scripting:
Open Automator, create a new Service, accepting files and folders from Finder, add a Run AppleScript action and type in following:
on run {...
4
votes
Accepted
Alias in bash to Change Directory
You need to escape/protect any spaces etc in the path:
alias cdicloud="cd ~/Library/Mobile\ Documents/com~apple~CloudDocs"
Executing this in Terminal looks like the following:
pse@Mithos:~$ alias ...
4
votes
Accepted
How can I create a Finder alias in a bash script that reads arguments from the command-line?
With minimal error handling:
#!/bin/sh
[ -f "$1" ] || exit 1
[ "$2" ] || exit 1
alias=$(basename "$2")
/usr/bin/osascript <<EOF
tell application "Finder"
set myapp to POSIX file "$1" as ...
4
votes
Accepted
List all aliases starting with a particular string
grep for them
Far better suggestion from the comments - grep on alias.
You can list all your aliases, even the ones not written in ~/.bash_profile, by calling alias.
grep the result to find the ...
4
votes
What is the "On My Mac" folder in macOS Big Sur?
In Big Sur, ~/Library/Containers shows in Finder as ‘On My Mac’.
This is a trimmed down version of the Documents from each of those containers, only showing apps which open their Documents on macOS ...
grg♦
- 206k
3
votes
Accepted
How to create a link, for multiple users, to a network share, which itself is on a network share?
Found the answer. You must create an .afploc file. This is similar to an .inetloc file.
The easiest way to create a .afploc file:
open Finder
Go -> Connect to Server
type the address in the ...
3
votes
Accepted
Recreate an alias with the same name and timestamp programmatically
Create a Service with Automator — Tested on macOS Sierra
Open /Applications/Automator.app
File > New (cmd-N)
Choose a type of document: "Service".
Service receives selected: "files or folders" in "...
3
votes
Accepted
Search for alias not finding files
Did you use the Alias command from the finder when you created the links, or did you use ln -s in the terminal? Unix symbolic links are not quite the same as an Alias although they serve similar ...
3
votes
Accepted
Alias - 'Show Original' in new tab
With the help of StackOverflow & starting from the ideas presented in both the answers from brw59 boris42, I now have this, by user3439894
on run {input, parameters}
set madeNewWindow to ...
3
votes
Accepted
The command for alias local='...' gets run on terminal open
I could not recreate what you have said is happening to you.
Saying that I would say that: It is really very dangerous to invoke local as your alias
Because the word local is a shell builtin, a ...
3
votes
MacOS zsh alias pwd is incorrect
The $(pwd) in your alias command is replaced immediately by its value returned from execution. This occurs at the creation of the alias, not when you want to use the alias. As shown after your first ...
grg♦
- 206k
3
votes
How can I place a shortcut to a network folder in my sidebar?
Wow, it looks like I have found a workable solution to this. Still a few strange bits which you can see in the new video I created, but the end result basically works.
Steps:
With the remote volume ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
alias × 202macos × 77
terminal × 59
finder × 46
bash × 37
symlink × 27
command-line × 20
applescript × 15
zsh × 11
email × 10
icloud × 8
mail.app × 8
filesystem × 7
folders × 7
backup × 6
dock × 6
network × 5
ios × 4
mac × 4
spotlight × 4
script × 4
icon × 4
desktop × 4
iterm × 4
launchpad × 4