Last active
August 15, 2023 04:32
-
-
Save khpatel4991/ae3dcdad41d18382d06f0a9bd6170964 to your computer and use it in GitHub Desktop.
my zinit
This file contains hidden or 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
OS=`echo \`uname\` | tr '[:upper:]' '[:lower:]'` | |
AURL="https://gist.githubusercontent.com/hightemp/5071909/raw/" | |
ANAME=".bash_aliases" | |
TMPAPATH="/tmp/$ANAME" | |
HOMEAPATH="~/$ANAME" | |
[ "$OS" = "windowsnt" ] && OS_WIN="yes" | |
[ "$OS" = "darwin" ] && OS_MAC="yes" | |
[ "$OS" = "linux" ] && OS_LIN="yes" | |
# Self-update | |
alias alias_update="rm -f $TMPAPATH;wget $AURL -O $TMPAPATH;mv $TMPAPATH $HOMEAPATH;source $HOMEAPATH" | |
# ls variants | |
alias la='ls -A' | |
alias l='ls -alFtr' | |
alias lsd='ls -d .*' | |
alias ll='ls -alF' | |
[ -n "$OS_LIN" ] && alias ls='ls --color=auto' | |
[ -n "$OS_MAC" ] && alias ls='ls -G' | |
# Various | |
alias h='history | tail' | |
alias hg='history | grep' | |
alias mvi='mv -i' | |
alias rmi='rm -i' | |
alias {ack,ak}='ack-grep' | |
# Directories | |
alias {up,..}='cd ..' | |
# coreutils | |
# Commands also provided by macOS and the commands dir, dircolors, vdir have been installed with the prefix "g". | |
# If you need to use these commands with their normal names, you can add a "gnubin" directory to your PATH with: | |
PATH="/opt/homebrew/opt/coreutils/libexec/gnubin:$PATH" | |
# Git | |
alias gcl='git clone ' | |
alias gst='git status' | |
alias {gbra,gb}='git branch' | |
alias {gco,go}='git checkout' | |
alias {gcob,gob}='git checkout -b ' | |
alias {gadd,ga}='git add ' | |
alias {gcom,gc}='git commit' | |
alias {gpul,gl}='git pull ' | |
alias {gpus,gh}='git push ' | |
alias glom='git pull origin master' | |
alias ghom='git push origin master' | |
alias gg='git grep ' | |
# Output | |
alias lcase="tr '[:upper:]' '[:lower:]'" | |
alias ucase="tr '[:lower:]' '[:upper:]'" | |
# System | |
alias df="df -h" | |
alias du="du -h" | |
[ -n "$OS_MAC" ] && alias nproc="sysctl hw.ncpu | awk '{print \$2}'" | |
CORES=`nproc` | |
JOBS=$(expr $CORES + 1) | |
alias make="make -j$JOBS" | |
function install_from_git { | |
URL=$1 | |
DIRNAME="/tmp/${URL##*/}" | |
gcl $URL $DIRNAME | |
pushd $DIRNAME | |
make | |
sudo make install | |
popd | |
rm -rf $DIRNAME | |
} | |
alias ifg="install_from_git " | |
if [ -n "$OS_MAC" ]; then | |
function free() { | |
FREE_BLOCKS=$(vm_stat | grep free | awk '{ print $3 }' | sed 's/\.//') | |
INACTIVE_BLOCKS=$(vm_stat | grep inactive | awk '{ print $3 }' | sed 's/\.//') | |
SPECULATIVE_BLOCKS=$(vm_stat | grep speculative | awk '{ print $3 }' | sed 's/\.//') | |
FREE=$((($FREE_BLOCKS+SPECULATIVE_BLOCKS)*4096/1048576)) | |
INACTIVE=$(($INACTIVE_BLOCKS*4096/1048576)) | |
TOTAL=$((($FREE+$INACTIVE))) | |
echo "Free: $FREE MB" | |
echo "Inactive: $INACTIVE MB" | |
echo "Total free: $TOTAL MB" | |
} | |
alias free="free" | |
fi | |
# Files | |
alias lcf="rename 'y/A-Z/a-z/' " | |
alias ucf="rename 'y/a-z/A-Z/' " | |
# Mac ports | |
if [ -n "$OS_MAC" ]; then | |
alias brewi='brew install' | |
alias brews='brew search' | |
alias porti='sudo port install' | |
alias ports='port search' | |
fi | |
# Grep | |
alias egrep='egrep --color=auto' | |
alias fgrep='fgrep --color=auto' | |
alias grep='grep --color=auto' | |
# DNS | |
alias {hostname2ip,h2ip}='dig +short' | |
# Mac DHCP service | |
if [ -n "$OS_MAC" ]; then | |
alias {dhcpup,dhcp-start}='sudo /bin/launchctl load -w /System/Library/LaunchDaemons/bootps.plist' | |
alias {dhcpdn,dhcp-stop}='sudo /bin/launchctl unload -w /System/Library/LaunchDaemons/bootps.plist' | |
fi | |
# Clipboard | |
[ -n "$OS_MAC" ] && alias getcb='pbpaste' | |
[ -n "$OS_WIN" ] && alias getcb='cat /dev/clipboard' | |
[ -n "$OS_LIN" ] && alias getcb='xclip -o' | |
# Wget | |
alias wgetncc='wget --no-check-certificate' | |
alias wgetc='wget `getcb`' | |
function wget_archive_and_extract { | |
URL=$1 | |
FILENAME=${URL##*/} | |
wget $URL -O $FILENAME | |
extract $FILENAME | |
rmi $FILENAME | |
} | |
alias wgetae='wget_archive_and_extract ' | |
alias wgetaec='wgetae getcb' | |
# Utils | |
alias sitecopy='wget -k -K -E -r -l 10 -p -N -F -nH ' | |
alias ytmp3='youtube-dl --extract-audio --audio-format mp3 ' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment