Skip to content

Instantly share code, notes, and snippets.

@TheLouisHong
Last active July 4, 2017 03:03
Show Gist options
  • Save TheLouisHong/365dd688a4143c4992b007ede0547533 to your computer and use it in GitHub Desktop.
Save TheLouisHong/365dd688a4143c4992b007ede0547533 to your computer and use it in GitHub Desktop.
Louis Hong .bashrc

Louis Hong .bashrc

Really barebone .bashrc that's useful for everyone.

How to install

Copy paste into your ~ directory

How to use

Dependencies (You can comment out the ones you don't want in the .bashrc, but trust me these are GOOD plugins)

Search for keyword DEPENDENCY, comment them out if you don't want to install.

Provided some ubuntu commands for your convenience.

Install git clone "https://github.com/clvv/fasd.git"; make install;

Install sudo apt-get install nvim

Install git clone --depth 1 https://github.com/junegunn/fzf.git ~/.fzf; ~/.fzf/install

What's next for beginners reading this

Cool, now you have a starter .bashrc.

  1. Next, learn TMUX. Modern OS experience in SSH/BASH, features include window management(Think of Windows 10) and session control (lock your ssh session and resume your session hours later).
  2. Next, learn VIM. Text editing is critical for using Linux through SSH/BASH. (I think)

Related

# ~/.bashrc: executed by bash(1) for non-login shells.
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
# for examples
# If not running interactively, don't do anything
case $- in
*i*) ;;
*) return;;
esac
# don't put duplicate lines or lines starting with space in the history.
# See bash(1) for more options
HISTCONTROL=ignoreboth
# append to the history file, don't overwrite it
shopt -s histappend
# for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
HISTSIZE=1000
HISTFILESIZE=2000
# check the window size after each command and, if necessary,
# update the values of LINES and COLUMNS.
shopt -s checkwinsize
# If set, the pattern "**" used in a pathname expansion context will
# match all files and zero or more directories and subdirectories.
#shopt -s globstar
# make less more friendly for non-text input files, see lesspipe(1)
[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
# set variable identifying the chroot you work in (used in the prompt below)
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
debian_chroot=$(cat /etc/debian_chroot)
fi
# set a fancy prompt (non-color, unless we know we "want" color)
case "$TERM" in
xterm-color|*-256color) color_prompt=yes;;
esac
# uncomment for a colored prompt, if the terminal has the capability; turned
# off by default to not distract the user: the focus in a terminal window
# should be on the output of commands, not on the prompt
#force_color_prompt=yes
if [ -n "$force_color_prompt" ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it's compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
xterm*|rxvt*)
PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1"
;;
*)
;;
esac
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
alias ls='ls --color=auto'
#alias dir='dir --color=auto'
#alias vdir='vdir --color=auto'
alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'
fi
# colored GCC warnings and errors
#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01'
# some more ls aliases
alias ll='ls -alF'
alias la='ls -A'
alias l='ls -CF'
# Add an "alert" alias for long running commands. Use like so:
# sleep 10; alert
alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
# Alias definitions.
# You may want to put all your additions into a separate file like
# ~/.bash_aliases, instead of adding them here directly.
# See /usr/share/doc/bash-doc/examples in the bash-doc package.
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
Above are from Instructor Matthew Mead at DigiPen
###################################
#VI Mode
set -o vi
# Make "g++" command call colorgcc
export PATH="/usr/lib/colorgcc/bin:$PATH"
#PS1 Prompt style
export PS1="\[\033[38;5;116m\]\u@\[$(tput sgr0)\]\[\033[38;5;115m\]\h\[$(tput sgr0)\]\[\033[38;5;15m\]:\[$(tput sgr0)\]\[\033[38;5;84m\]\w\[$(tput sgr0)\]\[\033[38;5;15m\]\n\[$(tput sgr0)\]\[\033[38;5;196m\]\\$\[$(tput sgr0)\]\[\033[38;5;15m\] \[$(tput sgr0)\]"
#Default c compilers
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
alias watch="watch --color "
#reopen vimsession
alias vims="vim -S vimsession"
#Turn warnings all the way up
alias c++="c++ -std=c++11 -g -Wall -Wextra"
#Open with default
alias default="xdg-open"
#Shallow directory tree command
alias treesd="tree -d -L 2"
#Better tree command
alias treed="tree -d"
#Shallow tree command
alias trees="tree -L 2"
#https://github.com/github/hub
alias git="hub"
#DEPENDENCY Comment this line out if you aren't using neovim
alias vim="nvim"
#Colorful dir
alias dir="dir -t --color --group-directories-first"
#File share on current dir
#SAFE auto kill version
alias webshare="timeout 10m SimpleHTTPServerWithUpload.py"
#DANGEROUS forever mode
alias webshare_forever="echo -e '\e[31m\e[21m\e[4m\e[7mDANGEROUS: THIS RUNS FOREVER\nDANGEROUS: THIS RUNS FOREVER\nDANGEROUS: THIS RUNS FOREVER\e[0m';SimpleHTTPServerWithUpload.py"
# My CS class instructor want's us to turn ALL warnings crazy high. Ok.
alias mead="g++ -Wall -Wextra -ansi -pedantic -Werror -g"
#DEPENDENCY Comment this line out if you aren't using neovim
alias vimdiff="nvim -d"
#1,000,000 numbers instead of 1000000
#export BLOCK_SIZE=\'1
#DEPENDENCY Comment this line out if you aren't using fasd
#Initialize FASD
eval "$(fasd --init auto)"
#DEPENDENCY Comment these line out if you aren't using fasd
# FASD aliases
alias c='fasd_cd -d'
alias v='f -e vim' # quick opening files with vim
alias m='f -e mplayer' # quick opening files with mplayer
alias o='a -e xdg-open' # quick opening files with xdg-open
#colorize man page
export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
export LESS_TERMCAP_md=$'\E[01;34m' # begin bold
export LESS_TERMCAP_me=$'\E[0m' # end mode
export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
export LESS_TERMCAP_so=$'\E[01;44;33m' # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m' # end underline
export LESS_TERMCAP_us=$'\E[01;32m' # begin underline
#Trying to get 256 color
if [[ $TERM == xterm ]]; then
TERM=xterm-256color
fi
if [[ $TERM == screen ]]; then
TERM=screen-256color
fi
#To enable this cycling method
#bind '"\t":menu-complete'
#alias ls="ls -l -t --group-directories-first --color"
# Git SSH Stuff
SSH_ENV=/home/loolo78/.ssh/environment
# start the ssh-agent
function start_agent {
echo "Initializing new SSH agent..."
# spawn ssh-agent
/usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
echo succeeded
chmod 600 "${SSH_ENV}"
. "${SSH_ENV}" > /dev/null
/usr/bin/ssh-add
}
if [ -f "${SSH_ENV}" ]; then
. "${SSH_ENV}" > /dev/null
ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
start_agent;
}
else
start_agent;
fi
#Calculator
=() {
calc="${@//p/+}"
calc="${calc//x/*}"
bc -l <<<"scale=10;$calc"
}
#DEPENDENCY Comment this line out if you aren't using fzf
[ -f ~/.fzf.bash ] && source ~/.fzf.bash
#DEPENDENCY Comment this line out if you aren't using fzf
# fh - repeat history
fh() {
eval $( ([ -n "$ZSH_NAME" ] && fc -l 1 || history) | fzf +s --tac | sed 's/ *[0-9]* *//')
}
#Enable CTRL+S
stty -ixon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment