Last active
September 5, 2018 06:31
-
-
Save bittracker/7664f64455f42cada164d1b10ce983c6 to your computer and use it in GitHub Desktop.
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
# VARS | |
VIM_PATH="/usr/bin/vim" | |
# If not running interactively, don't do anything | |
case $- in | |
*i*) ;; | |
*) return;; | |
esac | |
# BASH HISTORY | |
################# | |
HISTCONTROL=ignoreboth | |
shopt -s histappend | |
HISTSIZE=1000 | |
HISTFILESIZE=2000 | |
# STYLE | |
############# | |
shopt -s checkwinsize | |
# PROMPTS: | |
################ | |
# Show Debian chroot | |
if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then | |
debian_chroot=$(cat /etc/debian_chroot) | |
fi | |
# Detect Colors | |
case "$TERM" in | |
xterm-color) color_prompt=yes;; | |
xterm) color_prompt=yes;; | |
screen) color_prompt=yes;; | |
esac | |
if [ -n "$force_color_prompt" ]; then | |
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then | |
color_prompt=yes | |
else | |
color_prompt= | |
fi | |
fi | |
if [ "$color_prompt" = yes ]; then | |
# Color Prompt | |
if [ $UID -ne 0 ]; 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)}\[\033[01;31m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]# ' | |
fi | |
else | |
# Prompt without Colors | |
if [ $UID -ne 0 ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w# ' | |
fi | |
fi | |
unset color_prompt force_color_prompt | |
if [ "$SSH_CLIENT" != "" ]; then | |
EXT="REMOTE" | |
if [ -f /etc/production ]; then | |
EXT="\033[0;31mPRODUCTION\033[0m" | |
fi | |
PS1="[$EXT] $PS1" | |
fi | |
# TMUX | |
##################### | |
if [ -f "/usr/bin/tmux" ]; then | |
if [ $TERM != "screen" ]; then | |
if [ $? -ne 0 ]; then | |
# Create a new Session | |
tmux | |
else | |
# Pickup a existing session | |
tmux attach | |
fi | |
fi | |
fi | |
# DEFAULT COMMANDS: | |
###################### | |
alias ping="ping -c 10" | |
if [ $UID -ne 0 ]; then | |
alias apt-get="sudo apt-get" | |
alias shutdown="sudo shutdown" | |
alias reboot="sudo reboot" | |
alias journalclt="sudo journalclt --no-pager" | |
alias systemctl='sudo systemctl' | |
alias svi='sudo -E $EDITOR' | |
if [ -f /bin/systemd ]; then | |
alias cgls='sudo systemd-cgls' | |
alias cgtop='sudo systemd-cgtop' | |
fi | |
else | |
alias journalclt="journalclt --no-pager" | |
if [ -f /bin/systemd ]; then | |
alias cgls='systemd-cgls' | |
alias cgtop='systemd-cgtop' | |
fi | |
fi | |
if [ -f $VIM_PATH ]; then | |
alias vi="vim" | |
export VISUAL=$VIM_PATH | |
else | |
export VISUAL=vi | |
fi | |
# colorize output | |
if [ -x /usr/bin/dircolors ]; then | |
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" | |
alias ls='ls --color=auto' | |
alias grep='grep --color=auto' | |
export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' | |
fi | |
# ALIASES: | |
################## | |
if [ -f ~/.bash_aliases ]; then | |
. ~/.bash_aliases | |
fi | |
# BASH COMPLETION: | |
##################### | |
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 | |
# ENVs | |
############## | |
export EDITOR="$VISUAL" | |
export FCEDIT="$VISUAL" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment