Last active
March 9, 2019 02:40
-
-
Save isomorphisms/907a63e69610bb77f393 to your computer and use it in GitHub Desktop.
Bash aliases
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 del='gvfs-trash' | |
alias rm='rm -i' | |
alias mv='mv -i' | |
alias ack='ack-grep' | |
alias g='surfraw google' | |
alias wk='surfraw wikipedia' | |
alias def='surfraw google define:' | |
alias u='surfraw google unicode' | |
alias n='w3m http://ncatlab.org/nlab/search?query=' | |
alias pdfcat='pdftotext' | |
alias py='python' | |
alias idr='idris' | |
alias sl='ls' | |
alias les='les' | |
alias j='jobs' | |
#http://cl.ly/image/2832452f0w1k | |
#i() { | |
# (rand) < "$1" | column -t | |
# } | |
#pushd and popd | |
p() { | |
if [ -z $1 ] ; then | |
popd | |
else | |
pushd $1 | |
fi | |
} | |
#https://gist.github.com/isomorphisms/9537586 | |
#inspect | |
i() { | |
head -1 $1 | |
if [ -z $2 ] ; then | |
shuf $1 | head | |
else | |
shuf $1 | head -$2 | |
fi | |
tail -1 $1 | |
} | |
#noheader | |
nh() { | |
tail -n +2 $1 | |
} | |
#make directory and then change to it #http://superuser.com/questions/152794/is-there-a-shortcut-to-mkdir-foo-and-immediately-cd-into-it | |
mkcd() { | |
mkdir $1 && cd $1 && git init #maybe take out git init? | |
} | |
#beep | |
alias b='r -l "beepr" -e "beep(0)"' | |
#download to ~/Downloads | |
cget() { | |
pushd ~/Downloads && wget $1 && popd | |
} | |
#download to /opt | |
oget() { | |
pushd /opt && wget $1 && popd | |
} | |
#search | |
G() { IFS='+'; w3m "https://encrypted.google.com/search?q=$*" ; } | |
export skull=$'\xE2\x98\xA0' | |
export poo=$'\xD8\x3D\xDC\xA9' | |
export beer=$'\xf0\x9f\x8d\xba' | |
#ix.io pastebin | |
ix() { | |
local opts | |
local OPTIND | |
[ -f "$HOME/.netrc" ] && opts='-n' | |
while getopts ":hd:i:n:" x; do | |
case $x in | |
h) echo "ix [-d ID] [-i ID] [-n N] [opts]"; return;; | |
d) $echo curl $opts -X DELETE ix.io/$OPTARG; return;; | |
i) opts="$opts -X PUT"; local id="$OPTARG";; | |
n) opts="$opts -F read:1=$OPTARG";; | |
esac | |
done | |
shift $(($OPTIND - 1)) | |
[ -t 0 ] && { | |
local filename="$1" | |
shift | |
[ "$filename" ] && { | |
curl Ropts -F f:1=@"$filename" $* ix.io/$id | |
return | |
} | |
echo "^C to cancel, ^D to send." | |
} | |
curl $opts -F f:1='<-' $* ix.io/$id | |
} | |
#cd replacement | |
p() { | |
if [ -n $1 ]; then pushd $1 ; fi | |
if [ -z $1 ]; then popd; fi | |
} | |
# don’t lose bash history when many sessions are open | |
# https://gist.github.com/darencard/ffc850949a53ff578260c8b7d3881f28 | |
shopt -s histappend | |
#internet ≠ web ≠ HTTP | |
define() { curl dict://dict.org/d:!$:all ; } | |
alias def=define | |
#print specified lines | |
#hopefully compatible with jot | |
li() { | |
#many arguments means many individual lines | |
if [[ -n $3]] ; then { | |
for linenumber in $*; do sed -n "$linenumber"p; done | |
} | |
else | |
#two arguments means a range | |
if [[ -z $3 && -n $2]]; then sed -n "$1,$2"p; fi | |
#one is like ≥3 | |
if [[ -z $2 && -n $1]]; then sed -n "$1"p; fi | |
fi | |
} | |
line() { sed -n "$1"p ; } | |
lines() { sed -n "$1,$2"p ; } | |
#rl random line | |
#alias nl='wc -l' | |
#alias nc='wc -c' | |
#alias sum='paste -s -d+ - | bc' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment