80 lines
2.1 KiB
Bash
80 lines
2.1 KiB
Bash
#!/bin/zsh
|
|
|
|
# --- Basic Alias ---------------------------------------------
|
|
alias restart='clear; source ~/.zshrc; echo'
|
|
|
|
alias pd='pushd';
|
|
alias qd='popd';
|
|
alias lspd='dirs';
|
|
|
|
alias bp='clear; bpython';
|
|
|
|
alias pdo='pwd | xclip'; # [p]aste current [d]irectory [o]n clipboard
|
|
alias cdo='cd $(xclip -o)'; # [cd] to directory [o]n clipboard
|
|
|
|
alias disable_screen_blank='xset s 0'
|
|
alias color_demo='msgcat --color=test'
|
|
|
|
|
|
# --- !@#$ Aliases --------------------------------------------
|
|
alias sl='sl -alF | lolcat';
|
|
|
|
|
|
# --- GIT -----------------------------------------------------
|
|
alias gitbranchcleanup='git branch -d $(git branch | sed -E "/develop|master|\*/d")'
|
|
alias fix='vim $(git diff --name-only | uniq) -p';
|
|
|
|
alias github="OPEN_CURRENT_GIT_REPOSITORY_IN_WEB_BROWSER"
|
|
OPEN_CURRENT_GIT_REPOSITORY_IN_WEB_BROWSER() {
|
|
local REMOTE;
|
|
[ $1 ] && REMOTE="$1" || REMOTE="origin";
|
|
|
|
git remote get-url $REMOTE >/dev/null 2>&1 || {
|
|
echo "no remote called '$REMOTE' here";
|
|
return 1;
|
|
}
|
|
local URL="$(git remote get-url $REMOTE | sed 's/git@\([^:]*\):/http:\/\/\1\//')"
|
|
[ "$WEBBROWSER" ]\
|
|
&& "$WEBBROWSER $URL" >/dev/null 2>&1 \
|
|
|| dg-open $URL >/dev/null 2>&1 \
|
|
|| echo $URL;
|
|
}
|
|
|
|
|
|
# --- Miscellaneous -------------------------------------------
|
|
export RIPGREP_CONFIG_PATH="$HOME/.config/ripgrep/config";
|
|
|
|
alias erg='EDIT_RIP_GREP_FILE_MATCHES';
|
|
EDIT_RIP_GREP_FILE_MATCHES() {
|
|
[ $EDITOR = "vim" ] \
|
|
&& $EDITOR -p $(rg --color=never -l $1 ) \
|
|
|| $EDITOR $(rg --color=never -l $1) ;
|
|
}
|
|
|
|
|
|
alias monitor_connection='PING_MONITOR_GLOBAL_INTERNET_CONNECTION';
|
|
PING_MONITOR_GLOBAL_INTERNET_CONNECTION() {
|
|
local DELIMITER="\n==============================\n";
|
|
local CONNECTION_MONITOR_FILE="$HOME/.local/connection"
|
|
|
|
[ ! -f $CONNECTION_MONITOR_FILE ] && touch $CONNECTION_MONITOR_FILE;
|
|
|
|
echo "Attempting first connection....";
|
|
|
|
while true; do
|
|
ping 8.8.8.8 -c 5 > $CONNECTION_MONITOR_FILE;
|
|
clear;
|
|
|
|
printf "$DELIMITER\n" | lolcat;
|
|
|
|
grep "packet loss" $CONNECTION_MONITOR_FILE | sed 's/^.*, \(.*% packet loss\).*$/\1/' | lolcat;
|
|
echo;
|
|
|
|
grep 'bytes from' $CONNECTION_MONITOR_FILE | lolcat;
|
|
|
|
printf "\n$DELIMITER" | lolcat;
|
|
|
|
sleep 30;
|
|
done;
|
|
}
|