My Bash RC

Personal Bash aliases and helper functions that streamline my Laravel and Homestead development workflow.

~2 min read updated Jul 17, 2026 Bash
  • #bash
  • #bashrc
  • #git bash
  • #homestead
  • #laravel

This page documents the custom functions and aliases I keep in my .bashrc for day-to-day development.

Change Laravel Environment

Quickly update the environment inside a Laravel project's .env file without opening it in a text editor.

Function

function env() {
    if [[ -z "$1" ]]; then
        echo "Usage: env <value>"
        return 1
    fi

    if grep -q '^APP_ENV=' .env 2>/dev/null; then
        sed -i "s/^APP_ENV=.*/APP_ENV=$1/" .env
        echo ".env updated: APP_ENV=$1"
    elif grep -q '^ENV=' .env 2>/dev/null; then
        sed -i "s/^ENV=.*/ENV=$1/" .env
        echo ".env updated: ENV=$1"
    else
        echo "No ENV or APP_ENV found in .env, adding ENV=$1"
        echo "ENV=$1" >> .env
    fi
}

Usage

env local
env production
env testing

This updates:

APP_ENV=local

without manually editing the .env file.


Homestead Directory

Set the location of your Laravel Homestead installation.

HOMESTEAD_DIR="/c/Users/joshu/~/Homestead"

Workspace directory.

WORKSPACE_DIR="/c/Users/joshu/OneDrive/Desktop"

Update these paths if your directories are different.


Instead of remembering where Homestead is installed, use a helper function.

Function

function hm-cd() {
    cd "$HOMESTEAD_DIR" || {
        echo "Homestead directory not found: $HOMESTEAD_DIR"
        return 1
    }
}

Usage

hm-cd

Homestead Aliases

Start Homestead

Starts the virtual machine and provisions it.

alias hm-start='hm-cd && vagrant up --provision'

Usage:

hm-start

SSH into Homestead

Connect to the Homestead virtual machine.

alias hm-ssh='hm-cd && vagrant ssh'

Usage:

hm-ssh

Stop Homestead

Gracefully shuts down the virtual machine.

alias hm-stop='hm-cd && vagrant halt'

Usage:

hm-stop

Reload Homestead

Reloads the VM and reprovisions it.

Useful after changing your Homestead.yaml.

alias hm-reload='hm-cd && vagrant reload --provision'

Usage:

hm-reload

Complete Configuration

function env() {
    if [[ -z "$1" ]]; then
        echo "Usage: env <value>"
        return 1
    fi

    if grep -q '^APP_ENV=' .env 2>/dev/null; then
        sed -i "s/^APP_ENV=.*/APP_ENV=$1/" .env
        echo ".env updated: APP_ENV=$1"
    elif grep -q '^ENV=' .env 2>/dev/null; then
        sed -i "s/^ENV=.*/ENV=$1/" .env
        echo ".env updated: ENV=$1"
    else
        echo "No ENV or APP_ENV found in .env, adding ENV=$1"
        echo "ENV=$1" >> .env
    fi
}

HOMESTEAD_DIR="/c/Users/joshu/~/Homestead"
WORKSPACE_DIR="/c/Users/joshu/OneDrive/Desktop"

function hm-cd() {
    cd "$HOMESTEAD_DIR" || {
        echo "Homestead directory not found: $HOMESTEAD_DIR"
        return 1
    }
}

alias hm-start='hm-cd && vagrant up --provision'
alias hm-ssh='hm-cd && vagrant ssh'
alias hm-stop='hm-cd && vagrant halt'
alias hm-reload='hm-cd && vagrant reload --provision'
Small Bash functions save an absurd amount of time over hundreds of development sessions. Typing hm-start is much nicer than navigating to the Homestead directory and remembering the exact Vagrant command every single time. Humans are excellent at forgetting repetitive commands, so let the shell do the remembering.

Related notes