Skip to content

Instantly share code, notes, and snippets.

@vikrum vikrum/.osx
Last active Oct 2, 2019

Embed
What would you like to do?
Vikrum's Most Excellent Antiques, Curiosities, and Dotfiles
defaults write com.apple.Safari IncludeDebugMenu 1
defaults write com.apple.dock no-bouncing -bool TRUE
defaults write com.apple.notificationcenterui bannerTime 1
defaults write -g ApplePressAndHoldEnabled -bool false
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
alias l='ls -al'
alias ..="cd .."
alias g=git
alias gs='git status'
alias gp='git pull'
alias n='cat > /dev/null'
alias sssh='ssh'
alias Grep='grep'
alias rmdss="find . -type f -name .DS_Store -exec rm '{}' \;"
alias httpd='python -m SimpleHTTPServer'
alias ppjson='python -m json.tool'
alias cn="netstat -n | awk '/^tcp/ {t[$NF]++}END{for(state in t){print state, t[state]} }'"
alias sips='sort -t . -k 1,1n -k 2,2n -k 3,3n -k 4,4n'
alias gips='grep -oE "([0-9]{1,3}\.){3}[0-9]{1,3}"'
alias jl="sed 'N;s/\n/ /;'"
alias kbj='for moo in {1..100}; do kill %${moo}; done'
alias nop='pbpaste | pbcopy'
alias chop='tr -s [[:space:]] "\012"'
alias camelchop="sed -e 's|\([A-Z][^A-Z]\)| \1|g' -e 's|\([a-z]\)\([A-Z]\)|\1 \2|g'"
alias lowercase="tr '[A-Z]' '[a-z]'"
alias titlecase='python3 -c "import sys; print(sys.stdin.read().title())"'
alias gpt="git push --tags origin master"
alias gbd="git branch | grep -v master | xargs git branch -D"
alias 4sp="sed -e 's/^/ /'"
alias aphid='node ~/dev/git/firebase-operations/firebase-aphid/aphid.js'
alias ets='date +%s'
alias etms='node -e "console.log(new Date().getTime())"'
alias urldecode='python -c "import sys, urllib as ul; [sys.stdout.write(ul.unquote_plus(l)) for l in sys.stdin]"'
alias urlencode='python -c "import sys, urllib as ul; [sys.stdout.write(ul.quote_plus(l)) for l in sys.stdin]"'
alias shuf="perl -MList::Util=shuffle -e'print((shuffle<>)[0])'"
export EDITOR="vi"
export FIGNORE=".svn"
export PATH=$HOME/bin:$HOME/bin/apache-maven-3.0.3/bin:/opt/local/bin:/opt/local/sbin:$PATH
shopt -s histappend
export HISTSIZE=123456
export HISTFILESIZE=$HISTSIZE
export HISTTIMEFORMAT="%d/%m/%y %T "
function vfj() {
vi `find . -type f -name $1.java`
}
function avg() {
awk 'sum += $1 { printf "%.2f\n", sum/NR }' | tail -1
}
function sum() {
awk 'sum += $1 { printf "%.2f\n", sum }' | tail -1
}
function e2d() {
perl -e "print scalar localtime $1"
}
function cf() {
cd $(dirname $1)
}
function dcert() {
if [ -n "$1" ]; then openssl s_client -showcerts -connect $1:443 < /dev/null | awk -v cmd="openssl x509 -text -noout" '/-----BEGIN/ { c = $0; next } c { c = c "\n" $0 } /-----END/ { print c|cmd; close(cmd); c = 0 }'; fi
}
function certexp() {
if [ -n "$1" ]; then
echo $1
openssl s_client -showcerts -connect $1:443 < /dev/null 2>&1 | awk -v cmd="openssl x509 -noout -subject -enddate" '/-----BEGIN/ { c = $0; next } c { c = c "\n" $0 } /-----END/ { print c|cmd; close(cmd); c = 0 }'
fi
}
function pw() {
LEN=71
if [ ! -z $1 ]; then LEN="$1"; fi
openssl rand -base64 $LEN | tr -dc 'a-zA-Z0-9' | cut -c1-${LEN}
}
function deltag() {
git tag -d $1
git push origin :refs/tags/$1
}
function sumk1() {
perl -ane '$h{ $F[0] } += $F[1]; END { for ( keys %h ) { printf qq[%s %d\n], $_, $h{ $_ } } }'
}
function stats() {
# http://stackoverflow.com/a/9790056
perl -e 'use List::Util qw(max min sum); @a=();while(<>){chomp;$sqsum+=$_*$_; push(@a,$_)}; $n=@a;$s=sum(@a);$a=$s/@a;$m=max(@a);$mm=min(@a);$std=sqrt($sqsum/$n-($s/$n)*($s/$n));$mid=int @a/2;@srtd=sort @a;if(@a%2){$med=$srtd[$mid];}else{$med=($srtd[$mid-1]+$srtd[$mid])/2;};print "n:$n sum:$s mean:$a std:$std med:$med max:$m min:$mm";'
}
export BLUE="$(tput setaf 4)"
export TEAL="$(tput setaf 87)"
export GREEN="$(tput setaf 2)"
export DGRAY="$(tput setaf 16)"
export NORMAL="$(tput setaf 15)"
function gitprompt() {
if [ -d ".git" ]; then
GITB=$(git branch 2> /dev/null | grep '^*' | sed -e 's/* \(.*\)/\1/')
if [ "$GITB" ]; then
echo "${BLUE}${GITB}${NORMAL} 💫"
echo -n "+"
fi
fi
}
PROMPT_COMMAND=__prompt_command
__prompt_command() {
local RET=$?
if [ $RET -eq 0 ]; then
PSTATUS="🤖"
else
PSTATUS="💩"
fi
}
PS1="\n\$(gitprompt)\$PSTATUS \h:\W\$ "
set -o vi
GPG_TTY=$(tty)
export GPG_TTY
export JAVA_HOME=$(/usr/libexec/java_home)
set nocompatible " OG VIM
set bs=2 " allow backspacing over everything in insert mode
set ai " always set autoindenting on
set viminfo='20,\"50 " read/write a .viminfo file, don't store more than 50 lines of registers
set history=50 " keep 50 lines of command line history
set ruler " show the cursor position all the time
" set nohlsearch " Stop the search highlighting
hi Search term=bold ctermfg=0 ctermbg=81
" set vb " Visual bell
syntax on
set noswapfile
set nobackup
set nowb
set encoding=utf-8
set showmatch
set matchtime=2
" rot13
map <F3> ggVGg?
map <F5> :% !xmllint --format -
" Open the file to the last cursor position
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
set rnu
au InsertEnter * :set nu
au InsertLeave * :set rnu
au FocusLost * :set nu
au FocusGained * :set rnu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.