Files and shell

Create a command shortcut (alias)

Type a short word instead of a long command you use all the time.

Fill these in once
  1. Save the shortcut and load it
    Terminal
    echo "alias gs='git status'" >> ~/.zshrc
    source ~/.zshrc

Check it worked

  1. Check what it runs
    Terminal
    alias gs
Undo it
  1. Remove it
    Terminal
    sed -i '' "/^alias gs=/d" ~/.zshrc && unalias gs
  1. Save the shortcut and load it
    Terminal · Ubuntu / Debian
    echo "alias gs='git status'" >> ~/.bashrc
    source ~/.bashrc

Check it worked

  1. Check what it runs
    Terminal · Ubuntu / Debian
    alias gs
Undo it
  1. Remove it
    Terminal · Ubuntu / Debian
    sed -i "/^alias gs=/d" ~/.bashrc && unalias gs
  1. Save the shortcut in your profile and load it
    PowerShell
    if (!(Test-Path $PROFILE)) { New-Item -Path $PROFILE -ItemType File -Force }
    Add-Content $PROFILE "function gs { git status @args }"
    . $PROFILE

    PowerShell shortcuts that include arguments have to be small functions, which is what this adds.

Check it worked

  1. Check what it runs
    PowerShell
    Get-Command gs | Select-Object -ExpandProperty Definition
Undo it
  1. Remove it
    PowerShell
    (Get-Content $PROFILE) | Where-Object { $_ -notmatch '^function gs ' } | Set-Content $PROFILE