Last active
August 4, 2016 01:08
-
-
Save ayroblu/2f121ef8ad5a3ddb3e50b5fe4494865e 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
#. /Users/blu/.profile | |
env shellshock="() { :; }; echo 'Shellshockable!'" bash -c "echo -n ''" | |
# Makes homebrew stuff work first | |
#export PATH='/usr/local/bin:$PATH' | |
# Makes colourful ls and such (more impressive stuff is abit further on | |
export CLICOLOR=1 | |
export LSCOLORS=GxFxCxDxBxegedabagaced | |
# ASSUMED: sets the size of the history file | |
HISTFILESIZE=250000 | |
export HISTTIMEFORMAT="%y-%m-%d %T " | |
# Sets vim shortcuts for bash | |
set -o vi | |
# maps the show everything human readable etc... | |
alias vi='vim' | |
alias ll='ls -lhaG' | |
alias fin='find . -name' | |
alias tree='tree -C' | |
alias less='less -r' | |
alias iip='ifconfig | grep inet' | |
alias exip='curl ip.appspot.com' | |
alias vibashrc='vi ~/.profile' # change to bashrc on other computers | |
alias lbashrc='. ~/.profile' | |
alias top='top -o cpu' | |
alias h='history | tail -50' | |
alias cp='cp -i' | |
alias mv='mv -i' | |
alias ln='ln -i' | |
alias grep='grep --color=auto' | |
alias egrep='egrep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias ..='cd ..' | |
alias ...='cd ../../' | |
alias l.='ls -d' ## Show hidden files ## | |
alias bc='bc -l' #4: Start calculator with math support | |
alias mkdir='mkdir -pv' #5: Create parent directories on demand | |
alias j='jobs -l' | |
#11: Control output ping | |
alias ping='ping -c 5' # 5 count | |
# Do not wait interval 1 second, go fast # | |
alias fastping='ping -c 100 -s.2' | |
alias header='curl -I' | |
alias headerc='curl -I --compress' # find out if remote server supports gzip / mod_deflate or not # | |
alias wget='wget -c' #27 Resume wget by default | |
alias df='df -H' | |
alias du='du -ch' | |
# show epoch time | |
alias epoch='date +%s' | |
#alias addbash='echo "alias thing="\"$(history -p !!)\" >> ~/.bashrc-extras' | |
# Can't access drive because in use | |
#sudo lsof | grep /Volumes/myDrive | |
# z folders | |
#. `brew --prefix`/etc/profile.d/z.sh | |
# For find and replace in files, recursive: | |
# find . -type f -name '*' -exec sed -i '' 's/this/that/' {} + | |
#export LC_CTYPE=C | |
#export LANG=C | |
# For find and replace of filenames: - only removes front - look these up | |
# find . -name '123*.txt' -type f -exec bash -c 'mv "$1" "${1/\/123_//}"' -- {} \; | |
# Convert crlf to lf | |
# find ./ -type f -exec dos2unix {} \; | |
# Delete files older than x days | |
# find ~/log-20* -mtime +3 -exec rm {} \; | |
# Inputrc type, Bash completion | |
if [[ $- = *i* ]]; then | |
bind 'set show-all-if-ambiguous on' # Single tab show all | |
#bind 'TAB:menu-complete' # Tab completes to full possible file name | |
#bind 'set completion-ignore-case on' # Ignore case completion | |
bind '"\e[Z": menu-complete' # Shift-Tab menu-complete | |
#bind '"\e[Z": "\e-1\C-i"' # Shift-Tab menu-complete-backwards | |
fi | |
# change to existing subdirectory | |
function cto { | |
local results=$(find . -iname "$@" -type d 2>&1 | grep -v 'Permission denied') | |
if [ $(echo "$results" | wc -l) == "1" ]; then | |
cd $results | |
else | |
echo "${results}" | head -10 | |
if [ $(echo "$results" | wc -l) > 10 ]; then | |
echo "..." | |
fi | |
fi | |
} | |
# ----------------------------------------- Macbook | |
. ~/.bashrc-personal | |
#------------------------------------------ colors | |
. ~/.bashrc-colors | |
# ----------------------------------------- Bash prompt | |
. ~/.bashrc-prompt | |
# ----------------------------------------- bash quick adds | |
. ~/.bashrc-extras | |
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting | |
export NVM_DIR="/Users/blu/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh" # This loads nvm |
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
# This file handles things to do with colors: Mac OSX | |
# ----------------------Print all colors: | |
#for i in {0..255} ; do | |
# printf "\x1b[38;5;${i}mcolour${i}\n" | |
#done | |
BOLD_FONT='\x1B[1m' | |
NORMAL_FONT='\x1B[0m' | |
NC='\x1B[0m' | |
BLACK='\x1B[0;30m' | |
BLUE='\x1B[0;34m' | |
GREEN='\x1B[0;32m' | |
CYAN='\x1B[0;36m' | |
RED='\x1B[0;31m' | |
PURPLE='\x1B[0;35m' | |
BROWN_ORANGE='\x1B[0;33m' | |
LIGHT_GRAY='\x1B[0;37m' | |
DARK_GRAY='\x1B[1;30m' | |
LIGHT_BLUE='\x1B[1;34m' | |
LIGHT_GREEN='\x1B[1;32m' | |
LIGHT_CYAN='\x1B[1;36m' | |
LIGHT_RED='\x1B[1;31m' | |
LIGHT_PURPLE='\x1B[1;35m' | |
YELLOW='\x1B[1;33m' | |
WHITE='\x1B[1;37m' | |
# ------------------------------------- Output stderr in red | |
# command 2> >(while read line; do echo -e "\e[01;31m$line\e[0m" >&2; done) | |
# find / -name 'hi' 2> >(while read line; do echo -e "$RED$line$NC" >&2; done) | |
# - http://askubuntu.com/questions/135214/pipable-command-to-print-in-color | |
function pRED { | |
# activate color passed as argument | |
echo -ne "`eval echo '$RED'`" | |
# read stdin (pipe) and print from it: | |
cat | |
# Note: if instead of reading from the pipe, you wanted to print | |
# the additional parameters of the function, you could do: | |
# shift; echo $* | |
# back to normal (no color) | |
echo -ne "${NC}" | |
} | |
function pCYAN { | |
echo -ne "`eval echo '$CYAN'`" | |
cat | |
echo -ne "${NC}" | |
} | |
function pCol { | |
if [ "${#}" -ne 1 ]; then | |
echo 'Need an argument' | |
return | |
fi | |
color=\$${1:-$@} | |
echo -ne "`eval echo ${color}`" | |
cat | |
echo -ne "${NC}" | |
} | |
function pColours { | |
echo 'BOLD_FONT ' | pCol BOLD_FONT | |
echo 'NORMAL_FONT ' | pCol NORMAL_FONT | |
echo 'NC ' | pCol NC | |
echo 'BLACK ' | pCol BLACK | |
echo 'BLUE ' | pCol BLUE | |
echo 'GREEN ' | pCol GREEN | |
echo 'CYAN ' | pCol CYAN | |
echo 'RED ' | pCol RED | |
echo 'PURPLE ' | pCol PURPLE | |
echo 'BROWN_ORANGE ' | pCol BROWN_ORANGE | |
echo 'LIGHT_GRAY ' | pCol LIGHT_GRAY | |
echo 'DARK_GRAY ' | pCol DARK_GRAY | |
echo 'LIGHT_BLUE ' | pCol LIGHT_BLUE | |
echo 'LIGHT_GREEN ' | pCol LIGHT_GREEN | |
echo 'LIGHT_CYAN ' | pCol LIGHT_CYAN | |
echo 'LIGHT_RED ' | pCol LIGHT_RED | |
echo 'LIGHT_PURPLE ' | pCol LIGHT_PURPLE | |
echo 'YELLOW ' | pCol YELLOW | |
echo 'WHITE ' | pCol WHITE | |
} |
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
alias cdcme='cd ~/Google_Drive/cme' | |
alias runNode='DEBUG=temp:* npm start' | |
alias rand='date +%s | shasum -a 256 | base64 | head -c 32 ; echo' | |
alias random='openssl rand -base64 32' | |
alias l='ls -A' | |
alias adb='/Users/blu/Library/Android/sdk/platform-tools/adb ' | |
alias fastboot='~/Library/Android/sdk/platform-tools/fastboot ' | |
alias cdayro='cd ~/Google_Drive/Ayro/' | |
alias dtmux='rmtrash ~/.tmux/resurrect' | |
alias reindexspotlight='sudo mdutil -E /' |
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
#----------------------------------Personal to this computer | |
# export DYLD_LIBRARY_PATH=${DYLD_LIBRARY_PATH}/Applications/MATLAB/MATLAB_Compiler_Runtime/v83/runtime/maci64:/Applications/MATLAB/MATLAB_Compiler_Runtime/v83/sys/os/maci64:/Applications/MATLAB/MATLAB_Compiler_Runtime/v83/bin/maci64: | |
export ECLIPSE_HOME=/Users/blu/Desktop/Software/eclipse | |
#export PATH=$PATH:/usr/local/opt/go/libexec/bin | |
export GOPATH=$HOME/Google_Drive/ws/temp/thing | |
#-------------- personal aliases | |
#alias vi='/Applications/MacVim.app/Contents/MacOS/Vim' | |
#alias vim='/Applications/MacVim.app/Contents/MacOS/Vim' | |
alias superrmrm='rm' | |
alias rm='echo "Please use rmtrash! (superrmrm for normal rm)"' | |
alias ampl='/Users/blu/Documents/amplide-demo/ampl' | |
alias eclim='$ECLIPSE_HOME/eclimd -Dosgi.instance.area.default=@user.home/Dropbox/Programming/javaWorkspace' | |
alias o='figlet -cw'`tput cols` | |
alias cpwd='echo -n $(pwd) | pbcopy' | |
alias uaicupdate='rsync -aPv ~/Dropbox/Github/uaic/html /Applications/MAMP/htdocs/' | |
alias diff='colordiff' # install colordiff package :) -------------Installed using brew install colordiff | |
alias mount='mount |column -t' #7: Make mount command output pretty and human readable format | |
# cd dirs | |
alias cdsoftproj='cd ~/Dropbox/Programming/javaWorkspace/SOFTENG751/src/project/' | |
alias cdsoftrep='cd ~/Dropbox/sharelatex/SOFTENG\ 751\ Project/' | |
alias cdrep='cd ~/Dropbox/sharelatex/ENGSCI\ Part\ 4\ Project\ Report/' | |
alias cduni='cd ~/Dropbox/University\ of\ Auckland/' | |
alias cdentrep='cd ~/Dropbox/University\ of\ Auckland/2015\ Quarter\ 1\ Winter/ENTRE\ 370/' | |
alias cdventure='cd ~/Dropbox/University\ of\ Auckland/2015\ Quarter\ 1\ Winter/ENTRE\ 459/' | |
alias cdjava='cd ~/Dropbox/Programming/javaWorkspace/' | |
alias cdsharelatex='cd ~/Dropbox/sharelatex' | |
alias cduaic='cd ~/Google_Drive/Github/uaic/' | |
alias cdbenlu.co='cd ~/Dropbox/Github/benlu.co/' | |
alias cdmamp='cd /Applications/MAMP/htdocs' | |
# misc | |
alias vihome='vim -p ~/Dropbox/Notes.txt ~/.vimrc ~/.bashrc*' | |
alias viuninotes='vim -p ~/Dropbox/"University of Auckland/2015 Quarter 2 Spring"/fin{435,453,450,457}notes.md' | |
alias matlabterm='/Applications/MATLAB_R2014b.app/bin/matlab -nojvm -nodisplay -nosplash' | |
alias matlabtermjvm='/Applications/MATLAB_R2014b.app/bin/matlab -nodesktop -nosplash' | |
#alias gce='gcutil --service_version="v1" --project="velvety-renderer-404" ssh --zone="us-central1-a" "base-instance"' | |
alias adb='/Users/blu/Desktop/Software/ADT/sdk/platform-tools/adb' | |
#Run achievement server | |
alias achievement="dev_appserver.py --host=0.0.0.0 ~/Dropbox/Github/achievement/" | |
# Proxy stuff | |
alias proxywifion='sudo networksetup -setsocksfirewallproxystate Wi-Fi on' #on / off | |
alias proxywifioff='sudo networksetup -setsocksfirewallproxystate Wi-Fi off' #on / off | |
# Show/Hide Hidden files in Finder | |
alias showhidden='defaults write com.apple.finder AppleShowAllFiles TRUE; killall Finder' | |
alias hidehidden='defaults write com.apple.finder AppleShowAllFiles FALSE; killall Finder' | |
# compile latex | |
function mklatex { | |
#local tempdir=/Users/blu/ws/comptex | |
if [[ ! $@ =~ .*\.tex ]]; then echo $@ ' is not TeX file!'; return; fi | |
local tempdir=comptex | |
mkdir $tempdir/ | |
latexmk -bibtex -output-directory=$tempdir -pdf -interaction=nonstopmode $@ 2>&1 | grep --color=auto "Error\|Warning\|Run" | |
echo makeindex $tempdir/${@%.tex}.nlo -s $tempdir/nomencl.ist -o $tempdir/${@%.tex}.nls | |
# makeindex $tempdir/${@%.tex}.nlo -s nomencl.ist -o $tempdir/${@%.tex}.nls | |
# latexmk -silent -bibtex -output-directory=$tempdir -pdf $@ | |
# Outputing | |
local cwd=${PWD##*/} | |
cp "$tempdir/${@%.tex}.pdf" "${cwd}.pdf" | |
open "${cwd}.pdf" | |
} | |
# rsync | |
function rsink { | |
if [ "${#}" -ne 2 ]; then | |
echo "Need a two directories" | |
else | |
rsync -aPvv --ignore-existing ${1} ${2} | |
rsync -aPvv --ignore-existing ${2} ${1} | |
fi | |
} | |
function srsink { | |
if [ "${#}" -ne 2 ]; then | |
echo "Need a two directories" | |
else | |
rsync -aPvv --ignore-existing -e ssh ${1} ${2} | |
rsync -aPvv --ignore-existing -e ssh ${2} ${1} | |
fi | |
} | |
function email { | |
if [ "${#}" -eq 3 ]; then | |
echo curl -G --data-urlencode\ {to="\"${1}\"",subject="\"${2}\"",body="\"${3}\""} benlu.co/mail | |
elif [ "${#}" -eq 4 ]; then | |
echo curl -G --data-urlencode\ {from="\"${1}\"",to="\"${2}\"",subject="\"${3}\"",body="\"${4}\""} benlu.co/mail | |
else | |
echo "Need (from), to, subject, body" | |
fi | |
} | |
function unyproxy { | |
ssh -ND 9876 uny & | |
proxywifion | |
read -p "Press enter to turn off proxy: " | |
proxywifioff | |
fg | |
} | |
function nzproxy { | |
#ssh -ND 9876 blu@benlu.co & | |
#ssh -ND 9876 blu@202.169.196.28 & | |
ssh -ND 9876 nz & | |
proxywifion | |
read -p "Press enter to turn off proxy: " | |
proxywifioff | |
fg | |
} | |
#---------------------- Matlab | |
function matlab { | |
if [ "${#}" -lt 1 ]; then | |
matlabterm | |
else | |
cat "$@" | matlabterm | |
fi | |
} | |
function jmatlab { | |
if [ "${#}" -lt 1 ]; then | |
matlabtermjvm | |
else | |
cat "$@" | matlabtermjvm | |
fi | |
} | |
# ------------------------------------Convert video to mp3 using vlc | |
function convertVideos { | |
# list=$(find /path/to/some/files/ -mindepth 3 -maxdepth 3 -name '*.dat') | |
#for file in /Users/blu/Music/Assorted\ Stuff/Videos/*.flv; do # edit this!!! | |
local VLC=~/Applications/VLC.app/Contents/MacOS/VLC | |
for file in "${@}"; do # edit this!!! | |
#/Applications/VLC.app/Contents/MacOS/VLC -I dummy "$file" --sout="#transcode{acodec=mp3,vcodec=dummy}:standard{access=file,mux=raw,dst=\"$(echo "$file" | sed 's/\.[^\.]*$/.mp3/')\"}" vlc://quit | |
$VLC -I dummy "$file" --sout="#transcode{acodec=mp3,vcodec=dummy}:standard{access=file,mux=raw,dst=\"$(echo "$file" | sed 's/\.[^\.]*$/.mp3/')\"}" vlc://quit | |
done | |
} | |
# -------------------------------------------------------- Quick add bash aliases | |
set -o history -o histexpand | |
function addbashfunc { | |
if [ "${#} " -ne 1 ]; then | |
echo "Need a single aliasname" | |
else | |
echo "alias ${1}='"$TEMPCMD"'" >> ~/.bashrc-extras | |
fi | |
} | |
alias addbash='TEMPCMD="$(history -p !!)"; addbashfunc' | |
# ---------------------------------------------------------------------------Git completion | |
source ~/codes/git-completion.bash | |
#-----------------------------------------------------------------------------RVM | |
export PATH="$PATH:$HOME/.rvm/bin" # Add RVM to PATH for scripting | |
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function* | |
#----------------found on: http://www.cyberciti.biz/tips/bash-aliases-mac-centos-linux-unix.html | |
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
# http://askubuntu.com/questions/123268/changing-colors-for-user-host-directory-information-in-terminal-command-prompt | |
################################################## | |
# Fancy PWD display function | |
################################################## | |
# The home directory (HOME) is replaced with a ~ | |
# The last pwdmaxlen characters of the PWD are displayed | |
# Leading partial directory names are striped off | |
# /home/me/stuff -> ~/stuff if USER=me | |
# /usr/share/big_dir_name -> ../share/big_dir_name if pwdmaxlen=20 | |
################################################## | |
bash_prompt_shortener() { | |
# How many characters of the $PWD should be kept | |
local pwdmaxlen=25 | |
# Indicate that there has been dir truncation | |
local trunc_symbol=".." | |
local dir=${PWD##*/} | |
pwdmaxlen=$(( ( pwdmaxlen < ${#dir} ) ? ${#dir} : pwdmaxlen )) | |
NEW_PWD=${PWD/#$HOME/\~} | |
local pwdoffset=$(( ${#NEW_PWD} - pwdmaxlen )) | |
if [ ${pwdoffset} -gt "0" ] | |
then | |
NEW_PWD=${NEW_PWD:$pwdoffset:$pwdmaxlen} | |
NEW_PWD=${trunc_symbol}/${NEW_PWD#*/} | |
fi | |
} | |
function setPrompt { | |
COLOR1="\[\033[1;33m\]" #First color | |
COLOR2="\[\033[0;33m\]" #Second color | |
NO_COLOR="\[\033[0m\]" #Transparent - don't change | |
case $TERM in | |
xterm*) | |
TITLEBAR="\[\033]0;\W:\s\007\]" | |
;; | |
*) | |
TITLEBAR="" | |
;; | |
esac | |
local dash_open="${COLOR1}-${COLOR2}-" | |
local dash_close="${COLOR2}-${COLOR1}-" | |
local spacer="${COLOR2}-" | |
local jobs_and_history="${COLOR2}(${COLOR1}\!${COLOR2}:${COLOR1}\j${COLOR2})" | |
local user_host="${COLOR2}(${COLOR1}\u${COLOR2}@${COLOR1}\H${COLOR2})" | |
local host="${COLOR2}(${COLOR1}\H${COLOR2})" | |
local root_or_not="${COLOR2}(${COLOR1}\\\$${COLOR2})" | |
local cwd="${COLOR2}(${COLOR1}\w${COLOR2})" | |
#PS1="${TITLEBAR}${COLOR1}-${COLOR2}-(${COLOR1}\!${COLOR2}:${COLOR1}\j${COLOR2})-(${COLOR1}\w${COLOR2})-${COLOR1}-\n-${COLOR2}-(${COLOR1}\u${COLOR2}@${COLOR1}\H${COLOR2})-(${COLOR1}\\\$${COLOR2})-${COLOR1}- ${NO_COLOR}" | |
#PS1="${TITLEBAR}${dash_open}${cwd}${spacer}${root_or_not}${dash_close}\n${dash_open}${jobs_and_history}${spacer}${host}${dash_close}${NO_COLOR} " | |
#PS2="${COLOR2}--${COLOR1}- ${NO_COLOR}" | |
#PS1="${TITLEBAR}${COLOR1}"'${NEW_PWD}'"${COLOR2}:\$${NO_COLOR} " | |
PS1="${TITLEBAR}${COLOR1}"'\h \w'"${COLOR2}:\$${NO_COLOR} " | |
#PS2="$spacer$dash_close$NO_COLOR " | |
} | |
bash_prompt_shortener | |
setPrompt | |
unset setPrompt | |
#Determine and display the exit Status of the last command, if non-zero. | |
function checkExitStatus() { | |
local status="$?" | |
local signal="" | |
local COLOR1="\033[0;0;33m" #First color | |
local COLOR2="\033[0;0;36m" #Second color | |
local NO_COLOR="\033[0m" #Transparent - don't change | |
if [ ${status} -ne 0 -a ${status} != 128 ]; then | |
# If process exited by a signal, determine name of signal. | |
if [ ${status} -gt 128 ]; then | |
signal="$(builtin kill -l $((${status} - 128)) 2>/dev/null)" | |
if [ "$signal" ]; then | |
signal="$signal" | |
fi | |
fi | |
echo -e "${COLOR1}[Exit ${COLOR2}${status} ${signal}${COLOR1}]${NO_COLOR}" 1>&2 | |
#echo -ne "${COLOR1}[Exit ${COLOR2}${status}${COLOR1} ${COLOR2}${signal}${COLOR1}]${NO_COLOR} " 1>&2 | |
fi | |
return 0 | |
} | |
print_prompt_time() { | |
printf "%*s\r" $(tput cols) "$(date '+%T')" | |
} | |
promptCmd() { | |
checkExitStatus | |
print_prompt_time | |
} | |
PROMPT_COMMAND=promptCmd |
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
[user] | |
name = Ben Lu | |
email = ben@ben-l.com | |
[color] | |
ui = true | |
[alias] | |
ci = commit -am | |
ll = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr - %cd) %C(bold blue)<%an>%Creset' -2 -U0 | |
l = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr - %ad) %C(bold blue)<%an>%Creset' -10 | |
p = push origin master | |
s = status | |
m = merge --no-ff | |
[core] | |
pager = less -+$LESS -R | |
[push] | |
default = matching |
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
" Ben Lu, vimrc | |
" :so ~/_vimrc " reloads vimrc, use in vim, not here | |
" ------------------------------------------------------------Main layout | |
set sw=2 sts=2 ts=2 number et is ai hls ru sc cursorline mouse=a "shiftwidth, softtabstop, tabstop, linenumbers, softtabs, incsearch, autoindent, highlight search, ruler line col number, showcmd | |
hi CursorLine cterm=bold,underline ctermbg=NONE ctermfg=NONE guibg=blue guifg=orange "Set cursor line highlight colours | |
set splitright splitbelow | |
set backspace=indent,eol,start "Without this, you can't backspace an indent or line | |
"au BufNewFile,BufRead * if &syntax == '' | setf java | endif "Set syntax to java if none set initially | |
" Tab completion, as much as possible, list options, then tab through each | |
" option | |
set wildmode=longest,list,full | |
set wildmenu | |
" ------------------------------------------------------------------Mappings | |
syntax on | |
set fdm=manual fdl=4 "foldmethod fdc=1 foldcolumn | |
"set shellcmdflag=-ic " Makes shell interactive, :! now runs all system calls | |
" set spell spelllang=en_nz " ]s [s ]S [S " next spelling error | |
imap <S-space> <Esc> | |
imap jj <Esc>l | |
imap jk <Esc> | |
nnoremap <C-a> ggVG | |
filetype plugin on | |
" copy and pasting | |
vmap <C-c> y:call system("pbcopy", getreg("\""))<CR> | |
nmap <C-v><C-v> :call setreg("\"",system("pbpaste"))<CR>p | |
" Highlight rows and columns with \l and \c, 'l to move, :match to remove | |
" highlighting | |
nnoremap <silent> <Leader>l ml:execute 'match Search /\%'.line('.').'l/'<CR> | |
nnoremap <silent> <Leader>c :execute 'match Search /\%'.virtcol('.').'v/'<CR> | |
"Tab mappings | |
" tab navigation like firefox | |
nnoremap { :tabprevious<CR> | |
nnoremap } :tabnext<CR> | |
nnoremap <C-t> :tabnew<CR> | |
"inoremap <C-{> <Esc>:tabprevious<CR> | |
"inoremap <C-}> <Esc>:tabnext<CR> | |
inoremap <C-t> <Esc>:tabnew<CR> | |
nnoremap ( :tabmove -1<cr> | |
nnoremap ) :tabmove +1<cr> | |
" Window mappings | |
nnoremap <C-h> <C-w>h | |
nnoremap <C-j> <C-w>j | |
nnoremap <C-k> <C-w>k | |
nnoremap <C-l> <C-w>l | |
" Scroll mappings | |
:map <ScrollWheelUp> <C-Y> | |
:map <ScrollWheelDown> <C-E> | |
" set directory=~/tmp//,.,/var/tmp//,/tmp// | |
if &diff == 'nodiff' | |
set shellcmdflag=-ic | |
endif | |
"-----------------------------Set pasting to automatically go paste mode | |
" - https://coderwall.com/p/if9mda | |
let &t_SI .= "\<Esc>[?2004h" | |
let &t_EI .= "\<Esc>[?2004l" | |
inoremap <special> <expr> <Esc>[200~ XTermPasteBegin() | |
function! XTermPasteBegin() | |
set pastetoggle=<Esc>[201~ | |
set paste | |
return "" | |
endfunction | |
"---------------------------- Moving cursor by display lines | |
" - http://vim.wikia.com/wiki/Move_cursor_by_display_lines_when_wrapping | |
noremap <buffer> <silent> k gk | |
noremap <buffer> <silent> j gj | |
noremap <buffer> <silent> 0 g0 | |
noremap <buffer> <silent> $ g$ | |
" --------------------------------Insert single character | |
nnoremap s :exec "normal i".nr2char(getchar())."\el"<CR> | |
nnoremap S :exec "normal a".nr2char(getchar())."\el"<CR> | |
" -------------------------------Extras | |
"/[^\x00-\x7F] | |
"p`[ | |
noremap p p`[ | |
" ---------------------------------------------Stuff I don't really understand | |
" Cursor Color | |
" if &term =~ "xterm\\|rxvt" | |
" " use an orange cursor in insert mode | |
" let &t_SI = "\<Esc>]12;orange\x7" | |
" " use a red cursor otherwise | |
" let &t_EI = "\<Esc>]12;red\x7" | |
" silent !echo -ne "\033]12;red\007" | |
" " reset cursor when vim exits | |
" autocmd VimLeave * silent !echo -ne "\033]112\007" | |
" " use \003]12;gray\007 for gnome-terminal | |
" endif | |
" When editing a file, always jump to the last cursor position | |
autocmd BufReadPost * | |
\ if ! exists("g:leave_my_cursor_position_alone") | | |
\ if line("'\"") > 0 && line ("'\"") <= line("$") | | |
\ exe "normal g'\"" | | |
\ endif | | |
\ endif | |
" Default mapping for mutli cursor (change at will) | |
let g:multi_cursor_next_key='<C-n>' | |
let g:multi_cursor_prev_key='<C-p>' | |
let g:multi_cursor_skip_key='<C-x>' | |
let g:multi_cursor_quit_key='<Esc>' | |
" Pathogen | |
" let g:pathogen_disabled = ['syntastic','vim-gitgutter','vim-jade','vim-javascript','vim-markdown','vim-stylus','vim-surround'] | |
let g:pathogen_disabled = [] | |
execute pathogen#infect() | |
" | |
"" --------------------------plugin settings | |
runtime macros/matchit.vim | |
let g:gitgutter_realtime = 0 | |
let g:gitgutter_eager = 0 | |
autocmd FileType python setlocal expandtab shiftwidth=4 softtabstop=4 | |
autocmd FileType markdown setlocal expandtab shiftwidth=4 softtabstop=4 | |
"autocmd FileType tex :SyntasticToggleMode " disable syntastic for tex (slow) | |
"au FileType tex setlocal nocursorline | |
"augroup markdown | |
" au! | |
" au BufNewFile,BufRead *.md,*.markdown setlocal filetype=ghmarkdown | |
"augroup END | |
" Syntastic settings | |
nnoremap <C-w>E :SyntasticCheck<CR> :SyntasticToggleMode<CR> | |
let g:syntastic_mode_map = { 'mode': 'passive', | |
\ 'active_filetypes': [], | |
\ 'passive_filetypes': [] } | |
set statusline+=%#warningmsg# | |
set statusline+=%{SyntasticStatuslineFlag()} | |
set statusline+=%* | |
let g:syntastic_always_populate_loc_list = 1 | |
let g:syntastic_auto_loc_list = 1 | |
let g:syntastic_check_on_open = 1 | |
let g:syntastic_check_on_wq = 0 | |
let g:syntastic_javascript_checkers = ['eslint'] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment