Update dotfiles/.profile, dotfiles/.bashrc, dotfiles/.zshrc

This commit is contained in:
Brian Zalewski 2022-10-28 04:22:57 +00:00
parent bd6258e3e6
commit c87357bb57
3 changed files with 124 additions and 146 deletions

View file

@ -177,36 +177,6 @@ export LESS_TERMCAP_us=$'\e[1;4;31m'
export LESSHISTFILE=- export LESSHISTFILE=-
### Functions ### Functions
glog() {
setterm -linewrap off 2>/dev/null
git --no-pager log --all --color=always --graph --abbrev-commit --decorate --date-order \
--format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' "$@" |
sed -E \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+ /├\1─╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m /\1├─╯\x1b\[m/' \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+/├\1╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m/\1├╯\x1b\[m/' \
-e 's/╮(\x1b\[[0-9;]*m)+\\/╮\1╰╮/' \
-e 's/╯(\x1b\[[0-9;]*m)+\//╯\1╭╯/' \
-e 's/(\||\\)\x1b\[m (\x1b\[[0-9;]*m)/╰╮\2/' \
-e 's/(\x1b\[[0-9;]*m)\\/\1╮/g' \
-e 's/(\x1b\[[0-9;]*m)\//\1╯/g' \
-e 's/^\*|(\x1b\[m )\*/\1⎬/g' \
-e 's/(\x1b\[[0-9;]*m)\|/\1│/g' |
command less -r "$([ $# -eq 0 ] && echo "+/[^/]HEAD")"
setterm -linewrap on 2>/dev/null
}
find() {
if [ $# = 1 ]; then
# shellcheck disable=SC2145
command find . -iname "*$@*"
else
command find "$@"
fi
}
rgafzf() { rgafzf() {
RG_PREFIX="rga --files-with-matches" RG_PREFIX="rga --files-with-matches"

View file

@ -1,60 +1,74 @@
# shellcheck disable=SC1090,SC1091
# Easy file sharing from the command line, using transfer.sh # Easy file sharing from the command line, using transfer.sh
transfer() { transfer() {
if [ $# -eq 0 ]; then if [ $# -eq 0 ]; then
echo -e "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2; echo -e "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2
return 1; return 1
fi; fi
if tty -s; then if tty -s; then
file="$1"; file="$1"
file_name=$(basename "$file"); file_name=$(basename "$file")
if [ ! -e "$file" ]; then if [ ! -e "$file" ]; then
echo "$file: No such file or directory">&2; echo "$file: No such file or directory" >&2
return 1; return 1
fi; fi
if [ -d "$file" ]; then if [ -d "$file" ]; then
file_name="$file_name.zip" ,; file_name="$file_name.zip"
(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,; (cd "$file" && zip -r -q - .) | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null,
else else
cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null; curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" <"$file" | tee /dev/null
fi; fi
else else
file_name=$1; file_name=$1
curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null; curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null
fi; fi
} }
# Install WebDriverAgent on iOS device # Install WebDriverAgent on iOS device
appiumwebdriver() { appiumwebdriver() {
read -p "Enter the UDID of the device you wish to install WebDriverAgent on: " UDID_INPUT # read -r "Enter the UDID of the device you wish to install WebDriverAgent on: " UDID_INPUT
mkdir -p Resources/WebDriverAgent.bundle mkdir -p Resources/WebDriverAgent.bundle
bash ./Scripts/bootstrap.sh -d bash ./Scripts/bootstrap.sh -d
cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent || return
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=${UDID_INPUT}' test xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination "id=${UDID_INPUT}" test
} }
# Change directories and view contents at the same time # Change directories and view contents at the same time
cl() { cl() {
DIR="$*"; DIR="$*"
# if no DIR given, go home # if no DIR given, go home
if [ $# -lt 1 ]; then if [ $# -lt 1 ]; then
DIR=$HOME; DIR=$HOME
fi; fi
builtin cd "${DIR}" && \ builtin cd "${DIR}" &&
# use your preferred ls command # use your preferred ls command
ls -F --color=auto ls -F --color=auto
} }
# Checks status of a website on downforeveryoneorjustme.com # Checks status of a website on downforeveryoneorjustme.com
down4me() { down4me() {
curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'; curl -s "http://www.downforeveryoneorjustme.com/$1" | sed '/just you/!d;s/<[^>]*>//g'
} }
# GAM - a command-line tool for Google Workspace. This alias will run gam or install gam if it is not already installed. # GAM - a command-line tool for Google Workspace. This alias will run gam or install gam if it is not already installed. Includes type check in case gam is aliased for git.
if ! type gam &>/dev/null; then
gam() { gam() {
if command -v gam >/dev/null; then if command -v gam >/dev/null; then
gam "$@" gam "$@"
else else
TMP="$(mktemp)" && curl -sSL https://git.io/install-gam >"$TMP" && bash "$TMP" TMP="$(mktemp)" && curl -sSL https://git.io/install-gam >"$TMP" && bash "$TMP"
gam "$"
fi
}
fi
find() {
if [ $# = 1 ]; then
# shellcheck disable=SC2145
command find . -iname "*$@*"
else
command find "$@"
fi fi
} }
@ -63,6 +77,28 @@ gitopen() {
git remote -v | head -n 1 | awk -F "@" '{print $2}' | awk -F " " '{print $1}' | sed 's/:/\//g' | sed 's/.git//g' | awk '{print "http://"$1}' | xargs open git remote -v | head -n 1 | awk -F "@" '{print $2}' | awk -F " " '{print $1}' | sed 's/:/\//g' | sed 's/.git//g' | awk '{print "http://"$1}' | xargs open
} }
glog() {
setterm -linewrap off 2>/dev/null
git --no-pager log --all --color=always --graph --abbrev-commit --decorate --date-order \
--format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' "$@" |
sed -E \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+ /├\1─╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m /\1├─╯\x1b\[m/' \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+/├\1╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m/\1├╯\x1b\[m/' \
-e 's/╮(\x1b\[[0-9;]*m)+\\/╮\1╰╮/' \
-e 's/╯(\x1b\[[0-9;]*m)+\//╯\1╭╯/' \
-e 's/(\||\\)\x1b\[m (\x1b\[[0-9;]*m)/╰╮\2/' \
-e 's/(\x1b\[[0-9;]*m)\\/\1╮/g' \
-e 's/(\x1b\[[0-9;]*m)\//\1╯/g' \
-e 's/^\*|(\x1b\[m )\*/\1⎬/g' \
-e 's/(\x1b\[[0-9;]*m)\|/\1│/g' |
command less -r "$([ $# -eq 0 ] && echo "+/[^/]HEAD")"
setterm -linewrap on 2>/dev/null
}
# Open Mac OS X desktop on a Linux machine # Open Mac OS X desktop on a Linux machine
macosx() { macosx() {
docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:big-sur docker run -it --device /dev/kvm -p 50922:10022 -v /tmp/.X11-unix:/tmp/.X11-unix -e "DISPLAY=${DISPLAY:-:0.0}" sickcodes/docker-osx:big-sur
@ -83,7 +119,7 @@ quickstart() {
# Generate a random string of X length # Generate a random string of X length
randomstring() { randomstring() {
if [ -z "$1" ]; then if [ -z "$1" ]; then
head /dev/urandom | tr -dc A-Za-z0-9 | head -c $1 ; echo '' head /dev/urandom | tr -dc A-Za-z0-9 | head -c "$1"
else else
echo "Pass the number of characters you would like the string to be. Example: randomstring 14" echo "Pass the number of characters you would like the string to be. Example: randomstring 14"
fi fi
@ -92,18 +128,18 @@ randomstring() {
# Reset Docker to factory settings # Reset Docker to factory settings
resetdocker() { resetdocker() {
set +e set +e
CONTAINER_COUNT=$(docker ps -a -q | wc -l) CONTAINER_COUNT="$(docker ps -a -q | wc -l)"
if [ "$CONTAINER_COUNT" -gt 0 ]; then if [ "$CONTAINER_COUNT" -gt 0 ]; then
docker stop $(docker ps -a -q) docker stop "$(docker ps -a -q)"
docker rm $(docker ps -a -q) docker rm "$(docker ps -a -q)"
fi fi
VOLUME_COUNT=$(docker volume ls -q | wc -l) VOLUME_COUNT="$(docker volume ls -q | wc -l)"
if [ "$VOLUME_COUNT" -gt 0 ]; then if [ "$VOLUME_COUNT" -gt 0 ]; then
docker volume rm $(docker volume ls -q) docker volume rm "$(docker volume ls -q)"
fi fi
NETWORK_COUNT=$(docker network ls -q | wc -l) NETWORK_COUNT="$(docker network ls -q | wc -l)"
if [ "$NETWORK_COUNT" -gt 0 ]; then if [ "$NETWORK_COUNT" -gt 0 ]; then
docker network rm $(docker network ls -q) docker network rm "$(docker network ls -q)"
fi fi
docker system prune -a --force docker system prune -a --force
} }
@ -257,13 +293,14 @@ fi
if command -v brew >/dev/null; then if command -v brew >/dev/null; then
### Go ### Go
export GOPATH="${HOME}/.local/go" export GOPATH="${HOME}/.local/go"
export GOROOT="$(brew --prefix golang)/libexec" GOROOT="$(brew --prefix golang)/libexec"
export GOROOT
export GO111MODULE=on export GO111MODULE=on
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin" export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
### ASDF ### ASDF
if [ -f "$(brew --prefix asdf)/libexec/asdf.sh" ]; then if [ -f "$(brew --prefix asdf)/libexec/asdf.sh" ]; then
. $(brew --prefix asdf)/libexec/asdf.sh . "$(brew --prefix asdf)/libexec/asdf.sh"
fi fi
fi fi

View file

@ -1,3 +1,6 @@
#!/usr/bin/env zsh
# shellcheck disable=SC1090,SC1091,SC2034,SC2154,SC2296
### Powerline ### Powerline
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
@ -104,6 +107,7 @@ zstyle ':completion:*' rehash true
zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s zstyle ':completion:*' select-prompt %SScrolling active: current selection at %p%s
zstyle ':completion:*' use-compctl false zstyle ':completion:*' use-compctl false
zstyle ':completion:*' verbose true zstyle ':completion:*' verbose true
# shellcheck disable=SC2016
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
# Key bindings # Key bindings
@ -147,7 +151,9 @@ export LESSHISTFILE=-
# If this is an xterm set the title to user@host:dir # If this is an xterm set the title to user@host:dir
case "$TERM" in case "$TERM" in
xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty) xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty)
precmd() { print -Pnr -- $'\e]0;%n@%m: %~\a' } precmd() {
print -Pnr -- $'\e]0;%n@%m: %~\a'
}
;; ;;
esac esac
@ -164,8 +170,7 @@ export LC_ALL="en_US.UTF-8"
# Plugin source helper # Plugin source helper
_source_plugin() { _source_plugin() {
local plugin_name="$1" local plugin_name="$1"
for basedir in /usr/share/zsh/plugins /usr/share for basedir in /usr/share/zsh/plugins /usr/share; do
do
plugin="$basedir/$plugin_name/$plugin_name.zsh" plugin="$basedir/$plugin_name/$plugin_name.zsh"
[ -f "$plugin" ] && source "$plugin" && return 0 [ -f "$plugin" ] && source "$plugin" && return 0
done done
@ -227,8 +232,7 @@ unset -f _source_plugin
# POWERLEVEL # POWERLEVEL
if ! [[ $(tty) = /dev/tty* ]] if ! [[ $(tty) = /dev/tty* ]]
then then
if source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme 2> /dev/null if source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme 2> /dev/null; then
then
s=' ' # fix too wide icons s=' ' # fix too wide icons
POWERLEVEL9K_MODE=nerdfont-complete POWERLEVEL9K_MODE=nerdfont-complete
POWERLEVEL9K_SHORTEN_STRATEGY=truncate_beginning POWERLEVEL9K_SHORTEN_STRATEGY=truncate_beginning
@ -236,6 +240,7 @@ then
POWERLEVEL9K_PROMPT_ON_NEWLINE=true POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
# shellcheck disable=SC2016
POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT} $(whoami | grep -v "^root\$")' POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT} $(whoami | grep -v "^root\$")'
POWERLEVEL9K_OS_ICON_BACKGROUND=red POWERLEVEL9K_OS_ICON_BACKGROUND=red
POWERLEVEL9K_OS_ICON_FOREGROUND=white POWERLEVEL9K_OS_ICON_FOREGROUND=white
@ -310,39 +315,6 @@ switch_powerlevel_multiline_prompt(){
zle -N switch_powerlevel_multiline_prompt zle -N switch_powerlevel_multiline_prompt
bindkey ^P switch_powerlevel_multiline_prompt bindkey ^P switch_powerlevel_multiline_prompt
# -------------------------------- FUNCTIONS ---------------------------------
glog() {
setterm -linewrap off 2> /dev/null
git --no-pager log --all --color=always --graph --abbrev-commit --decorate --date-order \
--format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' "$@" \
| sed -E \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+ /├\1─╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m /\1├─╯\x1b\[m/' \
-e 's/\|(\x1b\[[0-9;]*m)+\\(\x1b\[[0-9;]*m)+/├\1╮\2/' \
-e 's/(\x1b\[[0-9;]+m)\|\x1b\[m\1\/\x1b\[m/\1├╯\x1b\[m/' \
-e 's/╮(\x1b\[[0-9;]*m)+\\/╮\1╰╮/' \
-e 's/╯(\x1b\[[0-9;]*m)+\//╯\1╭╯/' \
-e 's/(\||\\)\x1b\[m (\x1b\[[0-9;]*m)/╰╮\2/' \
-e 's/(\x1b\[[0-9;]*m)\\/\1╮/g' \
-e 's/(\x1b\[[0-9;]*m)\//\1╯/g' \
-e 's/^\*|(\x1b\[m )\*/\1⎬/g' \
-e 's/(\x1b\[[0-9;]*m)\|/\1│/g' \
| command less -r $([ $# -eq 0 ] && echo "+/[^/]HEAD")
setterm -linewrap on 2> /dev/null
}
find() {
if [ $# = 1 ]
then
command find . -iname "*$@*"
else
command find "$@"
fi
}
### Antigen ### Antigen
[[ ! -f ~/.local/antigen.zsh ]] || source ~/.local/antigen.zsh [[ ! -f ~/.local/antigen.zsh ]] || source ~/.local/antigen.zsh
@ -383,7 +355,6 @@ fi
fpath+=~/.zfunc fpath+=~/.zfunc
### zoxide ### zoxide
# TODO: Ensure zoxide.vim is installed
command -v zoxide > /dev/null && eval "$(zoxide init zsh)" command -v zoxide > /dev/null && eval "$(zoxide init zsh)"
### Fig ### Fig