Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 267 lines (224 sloc) 5.91 KB
#! /bin/bash
# Bash shortcuts
# enable color support of ls and also add handy aliases
if [ -x /usr/bin/dircolors ]; then
eval "`dircolors -b`"
alias ls='ls --color=auto'
alias grep='grep --color=auto'
fi
# ls
alias ll='ls -l'
alias lh='ls -lh'
alias la='ls -A'
alias lll='ls -Ahl'
alias les='/usr/share/vim/vim73/macros/less.sh'
llw() {
# easily find target of symlinks
ls -l $(which $1)
}
# Make grep more like ack.
# This alias may override ghostscript. That's not a problem for me.
alias gs='~/.vim/bundle/searchsavvy/bin/smartgrep --color=auto'
# windows work-alike
alias cls='clear'
alias tracert='tracepath'
function server_to_ip
{
# Use google's dns server to resolve IPs when local resolver is down.
nslookup -domain= $1 8.8.8.8
}
# python
#alias ipy='ipython'
alias ipy='screen -X title ipy ; ipython'
# Create using system-site-packages so I can use system ipython instead of
# installing in each virtualenv.
alias virtualcreate='virtualenv --system-site-packages v'
alias virtualon='. ./v/bin/activate'
android_sdks=~/data/.android_devkit
alias and_export_sdk='export PATH=$PATH:$android_sdks/android-sdk-linux/tools:$android_sdks/android-sdk-linux/platform-tools'
alias and_go_sdk='cd $android_sdks/android-sdk-linux/platform-tools'
#alias and_ndk_build='$android_sdks/android-ndk-r4b/ndk-build'
# Version control
alias g=git
# Completion: http://stackoverflow.com/questions/342969/how-do-i-get-bash-completion-to-work-with-aliases
complete -o default -o nospace -F _git g
function init_skeleton {
cp ../gitignore .gitignore
git init
git add .gitignore
git ci -m'Initial commit'
git add .
git ci -m'Project skeleton'
}
function set_aside_vim {
if [ -d ~/vimarchive ] ; then
echo ~/vimarchive already exists. Aborting to remain idempotent.
return
fi
mkdir ~/vimarchive
mv ~/.*vim* ~/vimarchive
mkdir -p ~/.vim/bundle
git clone ~/vimarchive/.vim/bundle/pathogen/ ~/.vim/bundle/pathogen/
git clone ~/vimarchive/.vim/bundle/sensible/ ~/.vim/bundle/sensible/
cat << EOF > ~/.vimrc
" On Windows, also use '.vim' instead of 'vimfiles'; this makes
" synchronization across (heterogeneous) systems easier.
if has('win32')
set runtimepath^=\$HOME/.vim
set runtimepath+=\$HOME/.vim/after
endif
" Load immediately -- it loads other plugins, so do it first.
runtime bundle/pathogen/autoload/pathogen.vim
call pathogen#infect()
set hlsearch
colorscheme desert
EOF
echo Basic vim setup complete
}
function vader
{
# Run vim tests in vader.
input=$*
if [ "$input" == "." -o "$input" == "" ] ; then
input='*'
fi
vim +"Vader! $input"
if [ $? -eq 0 ] ; then
echo Success
return 0
else
echo Failure
return 1
fi
}
function vader_isolated
{
# Run all vim tests in current director for containing plugin in isolated vader.
cwd=$(pwd)
plugin_dir=$(dirname $cwd)
if [[ $(basename $(dirname $plugin_dir)) != "bundle" ]]; then
echo "wd: $cwd"
echo "I don't think you're in a vim plugin's test directory."
echo "Expected something like: ~/.vim/bundle/vader/test/"
echo
read -p "Continue? " cont
if [[ $cont != "y" ]]; then
return 2
fi
fi
# Include the current directory since that's what we're testing. Sensible
# is most common options and textobj-user is a common dependency.
# Could also use gvim --nofork.
vim -Nu <(cat << VIMRC
filetype off
set rtp+=~/.vim/bundle/vader
set rtp+=~/.vim/bundle/sensible
set rtp+=~/.vim/bundle/textobj-user
set rtp+=$plugin_dir
set rtp+=~/.vim/bundle/textobj-user/after
set rtp+=$plugin_dir/after
filetype plugin indent on
VIMRC
) +"Vader! *"
if [ $? -eq 0 ] ; then
echo Success
return 0
else
echo Failure
return 1
fi
}
# Quick way to view files in vim
function v { $* | view - ; }
function __default_to_scratch
{
args=$*
if [ $# -lt 1 ] ; then
args="+ScratchNoSplit"
else
args="--remote-silent $args"
fi
echo $args
}
function ge
{
gvim `__default_to_scratch $*` 2> ~/.vim-cache/errors.log ;
}
function gide
{
gvim --servername VIDE `__default_to_scratch $*` 2> ~/.vim-cache/errors.log ;
}
function vv
{
vim --servername VIM `__default_to_scratch $*` 2> ~/.vim-cache/errors.log ;
}
function gvim_isolated
{
gvim -Nu NONE --servername MINVIM +'source ~/.vim/bundle/sensible/plugin/sensible.vim' +'colorscheme desert' $* 2> ~/.vim-cache/errors.log ;
}
function ec
{
# Open a client in a frame
emacsclient -c $*
if [ $? -ne 0 ] ; then
# Probably failed to connect to server, just start a new instance
# instead.
emacs $*
fi
}
function emacsd
{
# Manage the daemon.
# Must be started before calling `ec`.
# Killing/restarting will prompt for saving.
command=$1
case $command in
restart|kill)
echo "Requesting kill in emacsclient..."
emacsclient -c --eval '(david-server-shutdown)'
if [ $? -eq 0 ] ; then
echo "Failed to kill."
return
fi
;;
esac
case $command in
kill)
;;
*)
echo Starting...
emacs --daemon
;;
esac
}
function move_and_link() {
mv $1 $2
ln -sv $2 $1
}
# Start serving the local directory as a website
alias webserve='python -m SimpleHTTPServer'
DIR=~/data/settings/daveconfig/unix/terminal
#################
# Location-specific section
if [ -f $DIR/local.bash_aliases ]; then
source $DIR/local.bash_aliases
fi
#################
# Platform-specific section
# Used to use uname -o
# MinGW doesn't support uname -o
# -s is close (kernel name), so let's try that.
case "`uname -s`" in
MINGW*|CYGWIN*)
source $DIR/cygwin.bash_aliases
;;
Linux)
source $DIR/ubuntu.bash_aliases
;;
Darwin)
source $DIR/mac.bash_aliases
;;
*)
echo "bash_aliases: Platform not supported"
;;
esac