Skip to content

Instantly share code, notes, and snippets.

@egel
Created October 10, 2015 09:36
Show Gist options
  • Save egel/29fca2cdbbd4bcde4149 to your computer and use it in GitHub Desktop.
Save egel/29fca2cdbbd4bcde4149 to your computer and use it in GitHub Desktop.
Bash improver - simple script which add color prompt and man pages, popular aliases, 256 xterm color support, better bash history, and git-prompt (you can find it into my gists)
#!/bin/bash
# Bash Extras - personal configuration
RESET="\[\017\]"
NORMAL="\[\033[00m\]"
GREEN="\[\033[01;32m\]"
PURPLE="\[\033[01;35m\]"
BLUE="\[\033[01;34m\]"
RED="\[\033[31;1m\]"
YELLOW="\[\033[01;33m\]"
WHITE="\[\033[37;1m\]"
SMILEY="${WHITE}:)${NORMAL}"
FROWNY="${RED}:(${NORMAL}"
SELECT="if [ \$? = 0 ]; then echo \"${SMILEY}\"; else echo \"${FROWNY}\"; fi"
# Include git-prompt.sh script to show current branch in later PS1
source ~/dot-files/scripts/git-prompt.sh
PS1="${debian_chroot:+($debian_chroot)}${GREEN}\u${YELLOW}@${RED}\h${NORMAL}:${BLUE}\w${PURPLE}\$(__git_ps1)${NORMAL}\$ "
# History helper
export HISTCONTROL=ignoredups:erasedups # no duplicate entries
export HISTIGNORE="&:ls:[bf]g:exit" # ls without options and builtin commands
export HISTSIZE=100000 # big big history
export HISTFILESIZE=100000 # big big history
shopt -s histappend # append to history, don't overwrite it
shopt -s cmdhist # Combine multiline commands into one in history
# Save and reload the history after each command finishes
export PROMPT_COMMAND="history -a; history -c; history -r; $PROMPT_COMMAND"
# Add funny-dummy text to new instance of teminal
fortune | cowsay -W80 -f bud-frogs
# Manually add 256colors support for xTerm and tmux
export TERM="xterm-256color"
alias tmux="TERM=xterm-256color tmux"
# Add colors to man pages
export LESS_TERMCAP_mb=$'\E[01;31m' # enter blinking mode
export LESS_TERMCAP_md=$'\E[01;31m' # enter double-bright mode
export LESS_TERMCAP_me=$'\E[0m' # turn off all appearance modes (mb, md, so, us)
export LESS_TERMCAP_se=$'\E[0m' # leave standout mode
export LESS_TERMCAP_so=$'\E[01;44;33m' # enter standout mode – yellow
export LESS_TERMCAP_ue=$'\E[0m' # leave underline mode
export LESS_TERMCAP_us=$'\E[01;32m' # enter underline mode
# Some more ls aliases
alias ll="ls -l"
alias lo="ls -o"
alias lh="ls -lh"
alias la="ls -al"
alias l="ls"
alias s="ls"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment