From a400145eea19de97c6370696dd12212b7730b8be Mon Sep 17 00:00:00 2001 From: Tom Hicks Date: Fri, 20 Sep 2024 16:33:08 -0700 Subject: [PATCH] Adds aliases script. --- .rc.d/aliases.sh | 62 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 .rc.d/aliases.sh diff --git a/.rc.d/aliases.sh b/.rc.d/aliases.sh new file mode 100644 index 0000000..f943be4 --- /dev/null +++ b/.rc.d/aliases.sh @@ -0,0 +1,62 @@ +# File Manipulation +alias ls='ls -G --color=auto' +alias lsd='ls -G --color=auto -d' +alias ll='ls -G --color=auto -l' +alias lld='ls -G --color=auto -l -d' +alias lsg='ls | grep --color' +alias llg='ls -l| grep --color' +alias ln='ln -ivw' +alias grep='grep --color' +alias slash='ls -SlAhr' +alias slasher='ls -SlAh' +alias slashed='ls -SlAhrd' +alias dud='function { du -h -d 1 $* | sort -h }' +alias dudr='function { du -h -d 1 $* | sort -h -r }' +alias mvn='mv -n' +alias gmv='mv $* ~/Google\ Drive/My\ Drive/' +alias gmvn='mv -n $* ~/Google\ Drive/My\ Drive/' +alias omv='echo move to onedrive not yet implemented.' +alias omvn='echo move to onedrive without overwriting not yet implemented.' +alias gmv='mv $* ~/OneDrive/' +alias gmvn='mv -n $* ~/OneDrive/' +alias mv='mv -i' +alias rm='rm -i' +alias rs='rsync -avhz --no-perms' +alias ds='function { du -h -d 1 $* | sort -h | tee ~/dirsize }' +alias md=mkdir +alias rd=rmdir + +# Git shortcuts +alias it=git +alias rsgit='rsync -avhz --no-perms --exclude='\''.git'\'' --exclude='\''.vscode'\' + +# Bazel shortcuts +alias refresh_bazel='bazel run @hedron_compile_commands//:refresh_all' +alias bb='bazel build //...' +alias bt='bazel test //...' +alias bq='bazel query //...' +alias br='bazel run @hedron_compile_commands//:refresh_all' +alias cbb='clear && bazel build //...' +alias cbt='clear && bazel test //...' +alias cbq='clear && bazel query //...' + +# Utilities +alias iwyu='include-what-you-use' +alias show-android-emulators="ps aux | head -n 1 && ps aux | grep avd | sed '$d'" +alias kill-all-android-emulators='adb devices | grep emulator | cut -f1 | while read line; do adb -s $line emu kill; done' +alias freespace="df -I -h -T nodevfs | grep -i -v -E '/\.timemachine/|/System/Volumes/|/com\.apple\.TimeMachine\.localsnapshots/' | sed -e 's/ / /g'" +alias fs="df -I -h -T nodevfs | grep -i -v -E '/\.timemachine/|/System/Volumes/|/com\.apple\.TimeMachine\.localsnapshots/' | sed -e 's/ / /g'" +alias hashes='md5deep -r' +alias lsusb='system_profiler SPUSBDataType' +alias tea='tee -a' +alias find_recent='function { find . $* -exec ls -ltr {} + }' + +# In Development + +# Dosn't work if command is piped e.g. `log_and_do "ls | tee out.txt" my_other_file.txt` +# or stdout is redirected e.g. `log_and_do "ls > out.txt" my_other_file.txt` +alias log_and_do='function { `echo "# $1 >> $2\n" > $2 && echo $1` >> $2 }' + +# This should get the PIDs of any avd commands running and kill-9 them and then do the +# same as kill-all-android-emulators to clean them up after. +# alias kaae="kill -9 `ps aux | grep avd | sed '$d' | cut -f 2 -w` > /dev/null"