Permalink
Browse files

terminal enhancements

  • Loading branch information...
1 parent 60d6a7e commit bb9f68eecc6aca796b38eaa01dfa615ae6b1be7e @gabesoft committed Jun 3, 2011
Showing with 351 additions and 45 deletions.
  1. +33 −0 .bash_completion
  2. +52 −2 .bash_profile
  3. +81 −41 .bashrc
  4. +176 −0 .dir_colors
  5. +3 −1 .gitconfig
  6. +6 −1 .vimrc
View
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+shopt -s progcomp # Enable programmable completion.
+shopt -s hostcomplete # Complete host after @.
+shopt -s no_empty_cmd_completion # Don't complete on paste.
+
+complete -cf sudo # Enable crap sudo completion due to Compleat bug.
+complete -f -o default -X '!*.pl' perl perl5
+complete -f -o default -X '!*.rb' ruby ruby18 ruby19 bundlerb
+complete -f -o default -X '!*.py' python
+complete -f -o default -X '!*.applescript' osascript osacompile
+complete -f -X '!*.@(gif|GIF|jpg|JPG|jpeg|JPEG|png|PNG|xcf|bmp|BMP|pcx|PCX)' preview
+complete -f -X '!*.@(mp?(e)g|MP?(E)G|wma|avi|AVI|asf|vob|VOB|bin|dat|vcd|ps|pes|fli|viv|rm|ram|yuv|mov|MOV|qt|QT|wmv|mp3|MP3|ogg|OGG|ogm|OGM|mp4|MP4|wav|WAV|asx|ASX|mng|MNG|m4v)' quicktime
+complete -f -X '!*.@(tar|TAR|tgz|TGZ|tbz|TBZ|tbz2|TBZ2|txz|TXZ|tlz|TLZ|gz|GZ|bz2|BZ2|xz|XZ|lzma|LZMA|z|Z|zip|ZIP|rar|RAR|7z|7Z|deb|DEB)' extract
+
+complete -o default -F _longopt configure growlnotify softwareupdate
+complete -A directory cdll pushdll
+complete -o default -F _man manp
+complete -F _pgrep pidof
+
+complete -A alias alias unalias
+complete -A command which
+complete -A export export printenv
+complete -A hostname ssh telnet ftp ncftp ping dig nmap
+complete -A helptopic help
+complete -A job -P '%' fg jobs
+complete -A setopt set
+complete -A shopt shopt
+complete -A signal kill killall
+complete -A user su userdel passwd
+complete -A group groupdel groupmod newgrp
+complete -A directory cd rmdir
+
View
@@ -1,18 +1,68 @@
# .bash_profile
# get aliases and functions
-if [ -f ~/.bashrc ]; then
+# --------------------------------------------------------------------------------
+if [[ -f ~/.bashrc ]]; then
. ~/.bashrc
fi
+# paths
+# --------------------------------------------------------------------------------
+export PATH=$HOME/.local/bin:$HOME/.local/sbin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin$(cat /etc/paths.d/* | sed 's/^/:/g' | tr -d '\n')
+export MANPATH=$HOME/.local/share/man:/usr/local/share/man:/usr/share/man$(cat /etc/paths.d/* | sed 's/^/:/g' | tr -d '\n')
+
PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:/opt/local/bin:$PATH"
MANPATH=$MANPATH:/opt/local/share/man
INFOPATH=$INFOPATH:/opt/local/share/info
# bash completion
-if [ -f /opt/local/etc/bash_completion ]; then
+# --------------------------------------------------------------------------------
+if [[ -f /opt/local/etc/bash_completion ]]; then
. /opt/local/etc/bash_completion
+elif [[ -f ~/.bash_completion ]]; then
+ source ~/.bash_completion
+fi
+
+# git tab completion
+# --------------------------------------------------------------------------------
+if [[ -f ~/git-completion.bash ]]; then
+ source ~/git-completion.bash
fi
# add rvm
+# --------------------------------------------------------------------------------
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"
+
+# history
+# ------------------------------------------------------------------------------
+export HISTCONTROL="erasedupes"
+export HISTFILESIZE=409600
+export HISTIGNORE='history:&:ls:ll:la:[bf]g:h:exit:clear'
+export HISTSIZE=100000
+
+# grep colours
+# ------------------------------------------------------------------------------
+[[ "$TERM" != 'dumb' ]] && {
+ export GREP_OPTIONS="--color=auto"
+ export GREP_COLOR="37;45"
+}
+
+# editor
+# --------------------------------------------------------------------------------
+if [[ $platform == 'linux' ]]; then
+ export EDITOR='gvim -f'
+elif [[ $platform == 'mac' ]]; then
+ export EDITOR='/usr/local/bin/vim'
+fi
+
+# termcap colours
+# ------------------------------------------------------------------------------
+[[ "$TERM" != 'dumb' ]] && {
+ export LESS_TERMCAP_mb=$'\E[01;31m' # begin blinking
+ export LESS_TERMCAP_md=$'\E[01;31m' # begin bold
+ export LESS_TERMCAP_me=$'\E[0m' # end mode
+ export LESS_TERMCAP_se=$'\E[0m' # end standout-mode
+ export LESS_TERMCAP_so=$'\E[00;47;30m' # begin standout-mode
+ export LESS_TERMCAP_ue=$'\E[0m' # end underline
+ export LESS_TERMCAP_us=$'\E[01;32m' # begin underline
+}
View
122 .bashrc
@@ -1,11 +1,33 @@
# .bashrc
-# User specific aliases and functions
-# alias = list all aliases
-# cd = navigate home
-# cd - = navigate to previous folder
+# --------------------------------------------------------------------------------
+# options
+# --------------------------------------------------------------------------------
+set -o ignoreeof # Stop CTRL+D from logging me out.
+set -o noclobber # Prevent overwriting files with >.
+set -o notify # Notify of job termination.
+
+shopt -s cdspell # Spell check path
+shopt -s checkhash # Check program exists before executing.
+shopt -s checkwinsize # Wrap lines correctly after resizing terminal.
+shopt -s cmdhist # Remember multiline commands in history.
+shopt -s extglob # Use extended pattern matching.
+shopt -s histappend # Append to the history file.
+shopt -s histreedit # Allow re-editing of a failed substitution.
+shopt -s histverify # Don't execute retrieved history immediately; allow editing.
+shopt -s lithist # Don't reformat multi-line cmd into one line with semicolons.
+
+# history
+export HISTCONTROL=ignoredups
+# bash
+bind "set completion-ignore-case on"
+bind "set bell-style none"
+bind "set show-all-if-ambiguous on"
+
+# --------------------------------------------------------------------------------
# platform
+# --------------------------------------------------------------------------------
platform='unkown'
unamestr=`uname`
@@ -15,6 +37,19 @@ elif [[ "$unamestr" == "Darwin" ]]; then
platform='mac'
fi
+[[ "$TERM" != 'dumb' ]] && use_color='true' || use_color='false'
+[[ "$use_color" == 'true' ]] && {
+[[ "$(which dircolors)" ]] && use_color_gnu='true' || use_color_bsd='true'
+}
+
+# --------------------------------------------------------------------------------
+# aliases
+# --------------------------------------------------------------------------------
+
+# alias = list all aliases
+# cd = navigate home
+# cd - = navigate to previous folder
+
#navigation
alias ..='cd ..'
alias ...='cd .. ; cd ..'
@@ -40,11 +75,28 @@ alias scp='sudo cp -i'
alias scr='sudo cp -iR'
alias smv='sudo mv -i'
-# list directory
-# alias ls='ls --color=auto'
-alias ll='ls -hl'
-alias la='ls -a'
-alias lla='ls -lah'
+# ls family
+alias la='ls -AhF' # show hidden files
+alias lx='ls -AhlFT' # show hidden files (extended)
+alias ll='ls -lh' # long format
+alias lz='ls -lhS' # sort by size (extended)
+alias lt='ls -tA' # sort by time (most recent first)
+alias lT='ls -tlA' # sort by time (most recent first extended)
+alias lr='ls -lhR' # recursive (extended)
+
+# paths
+alias print-path='echo -e ${PATH//:/\\n}'
+alias print-libpath='echo -e ${LD_LIBRARY_PATH//:/\\n}'
+
+# curl
+alias get='curl -C - -O'
+
+# add colors for filetype recognition
+[[ "$use_color_gnu" == 'true' ]] && alias ls='ls -hF --group-directories-first --color=auto'
+[[ "$use_color_bsd" == 'true' ]] && alias ls='ls -G -F'
+
+# mkdir make intermediate directories
+alias mkdir='mkdir -p'
# grep / find
alias g='grep -i'
@@ -83,46 +135,32 @@ alias ver='cat /etc/redhat-release'
# list all colors
alias colors="set | egrep '^COLOR_\w*'"
-# git tab completion
-source ~/git-completion.bash
-
-# show git branch in status line
-export PS1="\[${COLOR_BROWN}\]\w\[${COLOR_CYAN}\]\$(__git_ps1)\[${COLOR_BROWN}\]> \[${COLOR_NC}\]"
-export PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~}\007"'
-
# save bookmarks to folders
# save x = bookmarks the current directory as x
# cd x = navigates to the bookmarked path
# smarks = displays all bookmarks
# cmarks = clears all bookmarks
if [ ! -f ~/.dirs ]; then # if doesn't exist, create it
- touch ~/.dirs
+ touch ~/.dirs
fi
alias smarks='cat ~/.dirs'
alias cmarks='rm -f ~/.dirs; touch ~/.dirs'
save (){
- command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ;
+ command sed "/!$/d" ~/.dirs > ~/.dirs1; \mv ~/.dirs1 ~/.dirs; echo "$@"=\"`pwd`\" >> ~/.dirs; source ~/.dirs ;
}
source ~/.dirs # Initialization for the above 'save' facility: source the .sdirs file
shopt -s cdable_vars # set the bash option so that no '$' is required when using the above facility
-# editor
-if [[ $platform == 'linux' ]]; then
- export EDITOR='gvim -f'
-elif [[ $platform == 'mac' ]]; then
- export EDITOR='/usr/local/bin/vim'
-fi
-
-# history
-export HISTCONTROL=ignoredups
-
-# bash
-bind "set completion-ignore-case on"
-bind "set bell-style none"
-bind "set show-all-if-ambiguous on"
+# --------------------------------------------------------------------------------
+# prompt: show git branch
+# --------------------------------------------------------------------------------
+export PS1="\[${COLOR_BROWN}\]\w\[${COLOR_CYAN}\]\$(__git_ps1)\[${COLOR_BROWN}\]> \[${COLOR_NC}\]"
+export PROMPT_COMMAND='echo -ne "\033]0;${PWD/$HOME/~}\007"'
+# --------------------------------------------------------------------------------
# colors
+# --------------------------------------------------------------------------------
# Black 0;30 Dark Gray 1;30
# Blue 0;34 Light Blue 1;34
@@ -133,17 +171,19 @@ bind "set show-all-if-ambiguous on"
# Brown 0;33 Yellow 1;33
# Light Gray 0;37 White 1;37
-export TERM=xterm-color
-export GREP_OPTIONS='--color=auto'
-export GREP_COLOR='1;31'
-export CLICOLOR=1
+#export CLICOLOR=1
+#export TERM=xterm-color
# shell colors
-if [[ $platform == 'linux' ]]; then
- export LS_COLORS='di=0;36:fi=0;37:ln=0;35:pi=5:so=5:bd=5:cd=5:or=31:mi=1:ex=0;31:*.rb=90'
-elif [[ $platform == 'mac' ]]; then
- export LSCOLORS=Gxfxcxdxbxegedabagacad
-fi
+#if [[ $platform == 'linux' ]]; then
+#export LS_COLORS='di=0;36:fi=0;37:ln=0;35:pi=5:so=5:bd=5:cd=5:or=31:mi=1:ex=0;31:*.rb=90'
+#elif [[ $platform == 'mac' ]]; then
+#export LSCOLORS=Gxfxcxdxbxegedabagacad
+#fi
+
+[[ "$use_color_gnu" == 'true' ]] && eval $(dircolors $HOME/.dir_colors)
+[[ "$use_color_bsd" == 'true' ]] && export CLICOLOR=1
+[[ "$use_color_bsd" == 'true' ]] && export LSCOLORS=Gxfxcxdxbxegedabagacad
export COLOR_NC='\033[0m' # No Color
export COLOR_WHITE='\033[1;37m'
Oops, something went wrong.

0 comments on commit bb9f68e

Please sign in to comment.