Shell 1 - My Startup Files

By Sheldon L Published at 2019-11-14 Updated at 2020-04-29


User Startup Files

~/.bashrc

# add a path shortcut
export PathName=/user_dir
# add a sub path shortcut under a parent path
export SubPathName=$ParentPathName/sub_dir
# add a new path to system's `PATH` (also called `environment variable`) after installing a software
export PATH=/dir_of_a_new_software_bin:$PATH  # must be named `PATH`

# restart terminal

~/.bash_aliases

# can be a single line start with `alias`
alias sthstart='systemctl start sth'
alias la='ls -a'

# or can be a block start with function, and quoted with `{}`
function apt-updater {
    sudo apt update
    sudo apt upgrade -Vy
    sudo apt autoremove -y
    sudo apt autoclean
    sudo apt clean
}

function v2-LA {
    sudo cp /dir/jsonfile /etc/v2ray/config.json
    sudo systemctl restart v2ray
    systemctl status v2ray
}

function quickpush {
    git add .
    git commit -m 'default quick push'
    git push
}

# restart terminal

~/.bash_profile

# add to `~/.bash_profile`
export PATH=/dir_of_a_new_software_bin:$PATH

# run manually
source ./bash_profile

Bash History Customization

export HISTCONTROL=ignoredups
export HISTIGNORE="&:ls:[bf]g:exit:history"
export HISTTIMEFORMAT='%F %T '