Skip to main content
This page documents all shell aliases and bash functions defined in the dotfiles.

Bash Aliases

Aliases are defined in dot_bash_aliases.tmpl and are automatically loaded by bash.

Basic Navigation

Simple shortcuts for common commands.
AliasCommandDescription
llls -lLong listing format
..cd ..Go up one directory
...cd ../..Go up two directories
tailftail -fFollow log file output
Example usage:
ll                    # List files in long format
..                    # cd ..
...                   # cd ../..
tailf /var/log/app.log # Tail log file

Network Utilities

Network diagnostics and information.
AliasCommandDescription
myipcurl -s ipinfo.io/ipShow public IPv4 address
myipv6curl -s ifconfig.meShow public IPv6 address
portsss -puntlList all open ports
psgrepps aux | grepSearch running processes
netgrepss -puntl | grepSearch open ports
Example usage:
myip                  # Display: 203.0.113.42
myipv6                # Display: 2001:db8::1
ports                 # List all listening ports
psgrep nginx          # Find nginx processes
netgrep 8080          # Check if port 8080 is open

Safety Aliases

Interactive prompts for destructive operations.
AliasCommandDescription
rmrm -IPrompt before removing 3+ files or recursive
cpcp -iPrompt before overwrite
mvmv -iPrompt before overwrite
lnln -iPrompt before overwrite
Safety explanation:
  • -I flag: Less intrusive than -i, only prompts for 3+ files or recursive delete
  • -i flag: Interactive mode, prompts before each overwrite
Example:
rm *.txt              # Prompts if more than 3 files
cp file.txt backup.txt # Prompts if backup.txt exists
mv old.txt new.txt    # Prompts if new.txt exists

System Utilities

Enhanced system commands with better defaults.
AliasCommandDescription
grepgrep --color=autoColorize grep output
fgrepfgrep --color=autoColorize fixed-string grep
egrepegrep --color=autoColorize extended grep
hhistoryShow command history
jjobs -lList background jobs
cclearClear terminal screen
dfdf -hHuman-readable disk space
dudu -hHuman-readable directory sizes
freefree -hHuman-readable memory info
Example usage:
grep error /var/log/app.log  # Highlights "error" in red
df                           # Shows disk space in GB/MB
du -s *                      # Show directory sizes
free                         # Display memory usage
h                            # Show recent commands

Git Aliases

Shortcuts for common git operations.
AliasCommandDescription
gsgit statusShow working tree status
gcogit checkoutSwitch branches or restore files
gcmgit commit -mCommit with message
gpsgit pushPush changes to remote
gplgit pullFetch and merge changes
gbgit branchList, create, or delete branches
gdgit diffShow changes
glgit log --onelineCompact log view
gagit addAdd files to staging
git_clean_branchesComplexRemove merged branches
Git clean branches:
git_clean_branches
# Expands to:
# git remote prune origin && git branch --merged | grep -v "\*" | xargs -n 1 git branch -d
This alias:
  1. Removes stale remote branches
  2. Finds all merged local branches
  3. Excludes current branch (*)
  4. Deletes each merged branch
Example usage:
gs                    # Check current status
ga .                  # Add all changes
gcm "Fix bug"         # Commit with message
gps                   # Push to remote
gco main              # Switch to main branch
gl                    # View recent commits
git_clean_branches    # Clean up old branches

Package Manager (Linux)

Convenient apt shortcuts (only on Linux systems).
AliasCommandDescription
installsudo apt installInstall packages
updatesudo apt updateUpdate package lists
upgradesudo apt upgradeUpgrade installed packages
searchapt searchSearch for packages
showapt showShow package details
Conditional loading:
{{- if eq .chezmoi.os "linux" }}
alias install='sudo apt install'
{{- end }}
Example usage:
search htop           # Find htop package
show htop             # View package info
install htop          # Install htop
update                # Update package lists
upgrade               # Upgrade all packages

Other Utilities

AliasCommandDescription
backuprsync -av --progressBackup files with progress
Example usage:
backup ~/documents /media/backup/documents
# Shows progress bar while copying

WSL-Specific Aliases

These aliases are only loaded when running in Windows Subsystem for Linux (WSL). Detection:
{{- if and (eq .chezmoi.os "linux") (contains "microsoft" .chezmoi.kernel.osrelease) }}
# WSL aliases here
{{- end }}

Windows Interop

Direct access to Windows executables from WSL.
AliasCommandDescription
cmdcmd.exe /cRun Windows Command Prompt commands
powershellpowershell.exeLaunch PowerShell
pwshpwsh.exeLaunch PowerShell Core
explorerexplorer.exeOpen Windows Explorer
notepadnotepad.exeOpen Notepad
openexplorer.exeOpen files/folders in default app
Example usage:
cmd ipconfig          # Run Windows ipconfig
explorer .            # Open current directory in Explorer
open file.pdf         # Open PDF in default viewer
notepad TODO.txt      # Edit in Notepad

Quick Windows Paths

Navigate to common Windows directories.
AliasPathDescription
cdwin/mnt/c/Users/{username}Windows user home
cddownloads/mnt/c/Users/{username}/DownloadsDownloads folder
cddesktop/mnt/c/Users/{username}/DesktopDesktop folder
cddocuments/mnt/c/Users/{username}/OneDrive/DocumentosDocuments folder
cdhome/home/{username}WSL home directory
Example usage:
cddownloads           # cd to Windows Downloads
cddesktop             # cd to Windows Desktop
cdhome                # Return to WSL home

Work-Specific (WSL)

Only available when machine_type is “work” or “hybrid”.
AliasCommandDescription
work-explorerexplorer.exe {work_path}Open work folder in Explorer
cdworkcd {work_repos_path}Navigate to work repositories
Conditional loading:
{{- if or (eq .machine_type "work") (eq .machine_type "hybrid") }}
alias cdwork='cd /mnt/c/Users/{{ .chezmoi.username }}/OneDrive/Documentos/work/repos'
{{- end }}

Personal-Specific (WSL)

Only available when machine_type is “personal” or “hybrid”.
AliasCommandDescription
cdreposcd {personal_repos}Navigate to personal repos
personal-explorerexplorer.exe {repos_path}Open repos in Explorer

Bash Functions

Custom bash functions defined in dot_bash_functions.

aws_env

Switch between AWS CLI profiles and export credentials as environment variables. Signature:
aws_env <profile_name>
Source code:
aws_env() {
profiles=$(aws configure list-profiles)
if echo "${profiles[@]:0}" | grep -q "^$1$" ; then
   AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id --profile "$1");
   AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key --profile "$1");
   AWS_DEFAULT_REGION=$(aws configure get region --profile "$1");
   export AWS_PROFILE=$1
   export AWS_ACCESS_KEY_ID
   export AWS_SECRET_ACCESS_KEY
   export AWS_DEFAULT_REGION
   echo "$1 environment variables exported";
   env | grep AWS_ | sort
else
   echo "profile '$1' not found"
   echo "profiles availables:"
   echo "${profiles[@]:0}"
fi
}
Behavior:
  1. Lists all available AWS profiles
  2. Checks if requested profile exists
  3. Reads credentials from ~/.aws/credentials
  4. Exports environment variables:
    • AWS_PROFILE
    • AWS_ACCESS_KEY_ID
    • AWS_SECRET_ACCESS_KEY
    • AWS_DEFAULT_REGION
  5. Displays all AWS environment variables
Example usage:
aws_env production
# Output:
# production environment variables exported
# AWS_ACCESS_KEY_ID=AKIA...
# AWS_DEFAULT_REGION=us-east-1
# AWS_PROFILE=production
# AWS_SECRET_ACCESS_KEY=***

aws s3 ls
# Now using production credentials
Error handling:
aws_env invalid
# Output:
# profile 'invalid' not found
# profiles availables:
# default
# production
# staging

bw_unlock

Unlock Bitwarden vault and export session token. Signature:
bw_unlock
Source code:
bw_unlock() {
    export BW_SESSION=$(bw unlock --raw)
    echo "Bitwarden vault unlocked"
}
Behavior:
  1. Prompts for master password
  2. Unlocks vault and gets session token
  3. Exports BW_SESSION environment variable
  4. All subsequent bw commands use this session
Example usage:
bw_unlock
# Prompts: Master password: ****
# Output: Bitwarden vault unlocked

bw get password github.com
# Now works without re-entering password
Session duration: The session remains active until you close the terminal or log out.

bw_status

Check current Bitwarden vault status. Signature:
bw_status
Source code:
bw_status() {
    bw status
}
Behavior: Displays JSON output with vault status. Example output:
bw_status
# Locked:
# {"serverUrl":"https://bitwarden.com","lastSync":"2024-01-15T10:30:00.000Z","status":"locked"}

# After bw_unlock:
# {"serverUrl":"https://bitwarden.com","lastSync":"2024-01-15T10:30:00.000Z","status":"unlocked"}

# Not logged in:
# {"serverUrl":null,"lastSync":null,"status":"unauthenticated"}
Status values:
  • unauthenticated - Not logged in (run bw login)
  • locked - Logged in but vault is locked (run bw_unlock)
  • unlocked - Vault is unlocked and ready to use

Loading Order

  1. ~/.bashrc sources ~/.bash_aliases
  2. ~/.bash_aliases contains all aliases
  3. ~/.bash_functions is sourced by bashrc
  4. Functions become available in all new shells

Customization

To add your own aliases:
chezmoi edit ~/.bash_aliases
# Add your aliases
chezmoi apply
source ~/.bash_aliases  # Reload in current shell
To add your own functions:
chezmoi edit ~/.bash_functions
# Add your functions
chezmoi apply
source ~/.bash_functions  # Reload in current shell

Build docs developers (and LLMs) love