Last active
August 17, 2020 12:17
Install .bashrc init code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
################################### | |
# Init content for .bashrc file | |
# | |
# curl -Ls https://gist.github.com/andkirby/0e2982bee321aa611bc66385dee5f399/raw/bashrc_init_install.sh | bash | |
# curl -Ls https://bit.ly/bash-init | bash | |
################################### | |
touch ~/.bashrc | |
if cat ~/.bashrc | grep '# Init .bashrc content' > /dev/null; then | |
echo "notice: You have updated .bashrc file." > /dev/stderr | |
exit 4 | |
fi | |
echo >> ~/.bashrc | |
curl -Ls https://gist.github.com/andkirby/0e2982bee321aa611bc66385dee5f399/raw/bashrc_z_base >> ~/.bashrc | |
echo >> ~/.bashrc | |
curl -Ls https://gist.github.com/andkirby/0e2982bee321aa611bc66385dee5f399/raw/bashrc_z_git >> ~/.bashrc | |
echo >> ~/.bashrc | |
curl -Ls https://gist.github.com/andkirby/0e2982bee321aa611bc66385dee5f399/raw/bashrc_z_default_dir >> ~/.bashrc | |
echo >> ~/.bashrc | |
echo 'Added initial ~/.bashrc content.' | |
echo 'Source: https://gist.github.com/andkirby/0e2982bee321aa611bc66385dee5f399' | |
echo 'Please run the command to get updates:' | |
echo ' $ . ~/.bashrc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# >>> Init .bashrc content | |
export SHELL=bash | |
export LS_OPTIONS='--color=auto' | |
# in some OS `dircolors` doesn't exist | |
eval "`dircolors 2> /dev/null || true`" | |
alias ls='ls $LS_OPTIONS' | |
alias ll='ls $LS_OPTIONS -lA' | |
alias l='ls $LS_OPTIONS -la' | |
alias rm='rm -i' | |
alias cp='cp -i' | |
alias mv='mv -i' | |
export TERM=xterm | |
export EDITOR=nano | |
# edit .bashrc file | |
alias bsh="${EDITOR} ~/.bashrc && source ~/.bashrc" | |
# <<< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == Use chanaged/default directory on load | |
DEFAULT_DIR=/d/home | |
# go to default directory | |
alias gh='cd '${DEFAULT_DIR} | |
# remember changed directory | |
cd() { builtin cd ${@} && keep_last_dir; } | |
keep_last_dir() { pwd > ~/.bashrc.last_dir; } | |
if [ -z "${BASHRC_INIT}" ]; then | |
export BASHRC_INIT=1 | |
readonly BASHRC_INIT | |
change_dir=${DEFAULT_DIR} | |
if [[ -f ~/.bashrc.last_dir ]]; then | |
change_dir=$(cat ~/.bashrc.last_dir) | |
fi | |
# go to default directory | |
[ -d ${change_dir} ] && cd ${change_dir} | |
fi | |
# <<< |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# == GIT shortcuts | |
alias gg='git status' | |
alias gl='git log -3' | |
alias glast='git reset --soft HEAD^' | |
alias gc='git add $(git diff --name-only --cached) && git commit -m' | |
alias ga='git add -u' | |
alias gd='git diff --cached' | |
alias gp='git push' | |
alias gpt='git push && git push --tags' | |
# <<< |
Short URL:
curl -Ls https://bit.ly/bash-init | bash
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
curl -Ls https://gist.github.com/andkirby/0e2982bee321aa611bc66385dee5f399/raw/bashrc_init_install.sh | bash