copied!
string MacPorts

[macos] Setting aliases for commands installed with MacPorts

created-2025/11/16 updated-2026/03/16

overview

To distinguish it from your usual environment, define aliases for the commands used in MacPorts.

procedure

  1. Creating an Alias ​​File
  2. Check if it was created
  3. Importing an Alias ​​File
  4. Check if the setting was successful

1. Creating an alias file

Create the following folder and alias file in your home folder, and append the string you want to set to the alias file.
Click to copy each line, paste it into Terminal, and press Enter.

mkdir ~/bashrc_folder
touch ~/bashrc_folder/macports_alias
echo 'alias hello_macports_alias="echo hello_macports_alias"' >> ~/bashrc_folder/macports_alias

2. Check if it was created

Verify that the bashrc_folder folder exists in your home folder and that the string you echoed is displayed in the macports_alias file.
Click and copy each line, paste it into Terminal, and press Enter.

ls -l ~
cat ~/bashrc_folder/macports_alias

3. Importing an Alias ​​File

Open Terminal and set up the alias with the following command:
Click the command to copy it, paste it into Terminal, and press Enter.

source ~/bashrc_folder/macports_alias

4. Check if the setting was successful

Run the hello_macports_alias command and if it displays hello_macports_alias, it’s OK.

hello_macports_alias

Points to note

Please note that the alias file will be cleared when you close the terminal, so you will need to reload the alias file the next time you open the terminal.

©︎ 2025-2026 todo