Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Configuration (.hashrc)

Hash shell supports configuration through a .hashrc file in your home directory.

Quick Start

Create your configuration file:

vim ~/.hashrc

Example .hashrc:

# Aliases
alias ll='ls -lah'
alias gs='git status'
alias gp='git push'

# Environment
export EDITOR=vim
export PATH=$HOME/bin:$PATH

# Prompt
set PS1='\W\g \e#>\e '

# Options
set colors=on
set welcome=off

Reload after editing:

source ~/.hashrc

Aliases

Define command shortcuts:

alias name='command'

Examples

# Navigation
alias ..='cd ..'
alias ...='cd ../..'

# Safety
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'

# Git
alias gs='git status'
alias ga='git add'
alias gc='git commit'
alias gp='git push'
alias gd='git diff'

# Docker
alias d='docker'
alias dc='docker-compose'
alias dps='docker ps'

Managing Aliases

# List all aliases
alias

# Show specific alias
alias ll

# Remove alias
unalias ll

Environment Variables

Set variables with export:

export VARIABLE=value
export VARIABLE='value with spaces'
export VARIABLE="value with $substitution"

Common Variables

# Editor
export EDITOR=vim
export VISUAL=vim

# Path
export PATH=$HOME/bin:$PATH

# Locale
export LANG=en_US.UTF-8

# Custom
export MY_PROJECT=~/projects/myapp

Shell Options

Configure behavior with set:

set option=value

Available Options

OptionValuesDescription
colorson/offEnable colored output
welcomeon/offShow welcome message
PS1formatCustom prompt
set colors=on
set welcome=off
set PS1='\W\g \e#>\e '

Prompt Customization

Set your prompt with the PS1 variable:

# Current directory + git + exit color
set PS1='\W\g \e#>\e '

# Full path + git
set PS1='\w\g \e#>\e '

# User@host:path
set PS1='\u@\h:\w\$ '

Escape Sequences

SequenceDescription
\wFull current path
\WCurrent directory name
\uUsername
\hHostname
\gGit branch with status
\eExit code color
\$$ for user, # for root
\nNewline

See Prompt Customization for complete details.

Comments

Lines starting with # are ignored:

# This is a comment
alias ll='ls -lah'  # Inline comment

Tips

Organize by Category

# ============================================================================
# NAVIGATION
# ============================================================================
alias ..='cd ..'
alias projects='cd ~/projects'

# ============================================================================
# GIT
# ============================================================================
alias gs='git status'
alias gp='git push'

Test Before Adding

Try aliases interactively first:

#> alias test='echo "works"'
#> test
works
# Now add to .hashrc

Reload After Changes

source ~/.hashrc

Troubleshooting

Alias Not Working

Check syntax (quotes required):

# Wrong
alias ll=ls -lah

# Correct
alias ll='ls -lah'

Variable Not Set

Use export:

# Wrong
MY_VAR=value

# Correct
export MY_VAR=value

Config Not Loading

Check file location and reload:

ls -la ~/.hashrc
source ~/.hashrc