Skip to content

Instantly share code, notes, and snippets.

@michaelnabil230
Last active May 23, 2025 07:56
Show Gist options
  • Select an option

  • Save michaelnabil230/90430f3b758b750dec00f748002f2252 to your computer and use it in GitHub Desktop.

Select an option

Save michaelnabil230/90430f3b758b750dec00f748002f2252 to your computer and use it in GitHub Desktop.
Aliases for macOS
# File operations
alias edit-aliases="code ~/.bash_aliases"
alias edit-zshrc="code ~/.zshrc"
# Laravel Artisan commands
alias a="php artisan"
alias art="php artisan"
alias serve="a serve"
alias mfs="a migrate:fresh --seed"
alias install-app="a project:install"
alias phpunit="clear && ./vendor/bin/phpunit"
alias pest="clear && ./vendor/bin/pestphp"
# Composer shortcuts
alias c="composer"
alias cr="c require"
alias ci="c install"
alias cu="c update"
alias cb="c bump"
alias laravel="~/.composer/vendor/bin/laravel new"
# Custom scripts from vendors
alias pint="./vendor/bin/pint"
alias phpstan="./vendor/bin/phpstan"
alias sail='[ -f sail ] && sh sail || sh vendor/bin/sail'
# SSH-related shortcuts
alias sshkey="cat ~/.ssh/id_rsa.pub"
alias sshconfig="code ~/.ssh/config"
alias copykey="command cat ~/.ssh/id_rsa.public | pbcopy"
# Alias help
alias alias-help=aliasHelpFunction
aliasHelpFunction() {
print_row() {
local title="$(bold "$(yellow "$1")")"
local padding=$((($COLUMNS - ${#title}) / 2))
printf "%-40s %-${padding}s" "$title" "$2"
echo
}
print_section() {
printf "\n$(bold $(green $1))\n\n"
}
print_end_section() {
echo
line
}
print_section "File operations"
print_row "edit-aliases" "Open ~/.bash_aliases in VS Code"
print_row "edit-bashrc" "Open ~/.bashrc in VS Code"
print_end_section
print_section "Laravel Artisan Commands"
print_row "a, art" "Run php artisan"
print_row "serve" "Run php artisan serve"
print_row "mfs" "Run php artisan migrate:fresh --seed"
print_row "install-app" "Run php artisan project:install"
print_row "phpunit" "Clear terminal and run ./vendor/bin/phpunit"
print_row "pest" "Clear terminal and run ./vendor/bin/pestphp"
print_end_section
print_section "Composer Shortcuts"
print_row "c" "Run composer"
print_row "cr" "Run composer require"
print_row "ci" "Run composer install"
print_row "cu" "Run composer update"
print_row "cb" "Run composer bump"
print_row "new-laravel" "Run composer create-project laravel/laravel"
print_end_section
print_section "Custom scripts from vendors"
print_row "pint" "Run ./vendor/bin/pint"
print_row "phpstan" "Run ./vendor/bin/phpstan"
print_end_section
print_section "SSH-Related Shortcuts"
print_row "sshkey" "Display contents of ~/.ssh/id_rsa.pub"
print_row "sshconfig" "Open ~/.ssh/config in VS Code"
print_row "copykey" "Copy contents of ~/.ssh/id_rsa.public to clipboard"
print_end_section
}
bold() {
echo -e "\033[1m$1\033[0m"
}
green(){
echo -e "\033[32m$1\033[0m"
}
yellow(){
echo -e "\033[33m$1\033[0m"
}
line() {
printf "%0$(tput cols)d" 0 | tr '0' '-'
echo
}

Bash aliases Configuration

This repository contains a collection of useful aliases and shortcuts designed to enhance your command-line experience. The provided .bash_aliases file includes shortcuts for various tasks, including file operations, Laravel Artisan commands, Composer operations, custom scripts, and SSH-related actions.

Table of Contents

Introduction

This repository provides a set of convenient aliases and shortcuts to simplify your command-line tasks. The aliases are organized into categories such as file operations, Laravel Artisan commands, Composer shortcuts, custom scripts, and SSH-related actions. These shortcuts are designed to save you time and effort by allowing you to execute common commands with fewer keystrokes.

Installation

To set up the aliases on your macOS system, follow these steps:

1. Backing Up Your Current Configuration

Before making any changes, it's recommended to back up your existing configuration files to avoid any accidental data loss. Open your terminal and execute the following commands:

cp ~/.bash_aliases ~/.bash_aliases.bak
cp ~/.zshrc ~/.zshrc.bak

2. Copying .bash_aliases

Copy the .bash_aliases file from this repository:

touch ~/.bash_aliases
code ~/.bash_aliases

3. Updating .zshrc

Open your .zshrc file in a text editor. If you're using Visual Studio Code, you can use the following command:

code ~/.zshrc

Add the following lines at the end of the .zshrc file to load the aliases:

# Source bash aliases if available
if [ -f ~/.bash_aliases ]; then
  builtin source ~/.bash_aliases
fi

4. Reloading Configuration

After saving the changes to your .zshrc file, reload the configuration to apply the changes without restarting your terminal:

source ~/.zshrc

Usage

Once the aliases are installed, you can start using them in your terminal. Here are a few examples:

  • To edit your aliases configuration:

    edit-aliases
  • To run a Laravel Artisan command:

    a migrate
  • To install a Composer package:

    cr package-name
  • To run custom scripts from vendors:

    pint

Refer to the full list of aliases and their explanations in the .bash_aliases file.

Alias Help

The .bash_aliases file includes an alias-help function that provides a quick overview of all defined aliases. You can use the following command to display the alias help:

alias-help
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment