Update dotfiles/.profile, dotfiles/.bashrc, dotfiles/.zshrc
This commit is contained in:
parent
bd6258e3e6
commit
c87357bb57
3 changed files with 124 additions and 146 deletions
|
@ -177,36 +177,6 @@ export LESS_TERMCAP_us=$'\e[1;4;31m'
|
|||
export LESSHISTFILE=-
|
||||
|
||||
### 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() {
|
||||
RG_PREFIX="rga --files-with-matches"
|
||||
|
|
|
@ -1,60 +1,74 @@
|
|||
# shellcheck disable=SC1090,SC1091
|
||||
|
||||
# Easy file sharing from the command line, using transfer.sh
|
||||
transfer() {
|
||||
if [ $# -eq 0 ]; then
|
||||
echo -e "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>">&2;
|
||||
return 1;
|
||||
fi;
|
||||
echo -e "No arguments specified.\nUsage:\n transfer <file|directory>\n ... | transfer <file_name>" >&2
|
||||
return 1
|
||||
fi
|
||||
if tty -s; then
|
||||
file="$1";
|
||||
file_name=$(basename "$file");
|
||||
file="$1"
|
||||
file_name=$(basename "$file")
|
||||
if [ ! -e "$file" ]; then
|
||||
echo "$file: No such file or directory">&2;
|
||||
return 1;
|
||||
fi;
|
||||
echo "$file: No such file or directory" >&2
|
||||
return 1
|
||||
fi
|
||||
if [ -d "$file" ]; then
|
||||
file_name="$file_name.zip" ,;
|
||||
(cd "$file"&&zip -r -q - .)|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null,;
|
||||
file_name="$file_name.zip"
|
||||
(cd "$file" && zip -r -q - .) | curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null,
|
||||
else
|
||||
cat "$file"|curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;
|
||||
fi;
|
||||
curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" <"$file" | tee /dev/null
|
||||
fi
|
||||
else
|
||||
file_name=$1;
|
||||
curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name"|tee /dev/null;
|
||||
fi;
|
||||
file_name=$1
|
||||
curl --progress-bar --upload-file "-" "https://transfer.sh/$file_name" | tee /dev/null
|
||||
fi
|
||||
}
|
||||
|
||||
# Install WebDriverAgent on iOS device
|
||||
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
|
||||
bash ./Scripts/bootstrap.sh -d
|
||||
cd /Applications/Appium.app/Contents/Resources/app/node_modules/appium/node_modules/appium-webdriveragent
|
||||
xcodebuild -project WebDriverAgent.xcodeproj -scheme WebDriverAgentRunner -destination 'id=${UDID_INPUT}' test
|
||||
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
|
||||
}
|
||||
|
||||
# Change directories and view contents at the same time
|
||||
cl() {
|
||||
DIR="$*";
|
||||
DIR="$*"
|
||||
# if no DIR given, go home
|
||||
if [ $# -lt 1 ]; then
|
||||
DIR=$HOME;
|
||||
fi;
|
||||
builtin cd "${DIR}" && \
|
||||
DIR=$HOME
|
||||
fi
|
||||
builtin cd "${DIR}" &&
|
||||
# use your preferred ls command
|
||||
ls -F --color=auto
|
||||
}
|
||||
|
||||
# Checks status of a website on downforeveryoneorjustme.com
|
||||
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() {
|
||||
if command -v gam >/dev/null; then
|
||||
gam "$@"
|
||||
else
|
||||
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
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
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
|
||||
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
|
||||
|
@ -83,7 +119,7 @@ quickstart() {
|
|||
# Generate a random string of X length
|
||||
randomstring() {
|
||||
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
|
||||
echo "Pass the number of characters you would like the string to be. Example: randomstring 14"
|
||||
fi
|
||||
|
@ -92,18 +128,18 @@ randomstring() {
|
|||
# Reset Docker to factory settings
|
||||
resetdocker() {
|
||||
set +e
|
||||
CONTAINER_COUNT=$(docker ps -a -q | wc -l)
|
||||
CONTAINER_COUNT="$(docker ps -a -q | wc -l)"
|
||||
if [ "$CONTAINER_COUNT" -gt 0 ]; then
|
||||
docker stop $(docker ps -a -q)
|
||||
docker rm $(docker ps -a -q)
|
||||
docker stop "$(docker ps -a -q)"
|
||||
docker rm "$(docker ps -a -q)"
|
||||
fi
|
||||
VOLUME_COUNT=$(docker volume ls -q | wc -l)
|
||||
VOLUME_COUNT="$(docker volume ls -q | wc -l)"
|
||||
if [ "$VOLUME_COUNT" -gt 0 ]; then
|
||||
docker volume rm $(docker volume ls -q)
|
||||
docker volume rm "$(docker volume ls -q)"
|
||||
fi
|
||||
NETWORK_COUNT=$(docker network ls -q | wc -l)
|
||||
NETWORK_COUNT="$(docker network ls -q | wc -l)"
|
||||
if [ "$NETWORK_COUNT" -gt 0 ]; then
|
||||
docker network rm $(docker network ls -q)
|
||||
docker network rm "$(docker network ls -q)"
|
||||
fi
|
||||
docker system prune -a --force
|
||||
}
|
||||
|
@ -257,13 +293,14 @@ fi
|
|||
if command -v brew >/dev/null; then
|
||||
### Go
|
||||
export GOPATH="${HOME}/.local/go"
|
||||
export GOROOT="$(brew --prefix golang)/libexec"
|
||||
GOROOT="$(brew --prefix golang)/libexec"
|
||||
export GOROOT
|
||||
export GO111MODULE=on
|
||||
export PATH="$PATH:${GOPATH}/bin:${GOROOT}/bin"
|
||||
|
||||
### ASDF
|
||||
if [ -f "$(brew --prefix asdf)/libexec/asdf.sh" ]; then
|
||||
. $(brew --prefix asdf)/libexec/asdf.sh
|
||||
. "$(brew --prefix asdf)/libexec/asdf.sh"
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
|
@ -1,3 +1,6 @@
|
|||
#!/usr/bin/env zsh
|
||||
# shellcheck disable=SC1090,SC1091,SC2034,SC2154,SC2296
|
||||
|
||||
### Powerline
|
||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
||||
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:*' use-compctl false
|
||||
zstyle ':completion:*' verbose true
|
||||
# shellcheck disable=SC2016
|
||||
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd'
|
||||
|
||||
# Key bindings
|
||||
|
@ -147,7 +151,9 @@ export LESSHISTFILE=-
|
|||
# If this is an xterm set the title to user@host:dir
|
||||
case "$TERM" in
|
||||
xterm*|rxvt*|Eterm|aterm|kterm|gnome*|alacritty)
|
||||
precmd() { print -Pnr -- $'\e]0;%n@%m: %~\a' }
|
||||
precmd() {
|
||||
print -Pnr -- $'\e]0;%n@%m: %~\a'
|
||||
}
|
||||
;;
|
||||
esac
|
||||
|
||||
|
@ -164,8 +170,7 @@ export LC_ALL="en_US.UTF-8"
|
|||
# Plugin source helper
|
||||
_source_plugin() {
|
||||
local plugin_name="$1"
|
||||
for basedir in /usr/share/zsh/plugins /usr/share
|
||||
do
|
||||
for basedir in /usr/share/zsh/plugins /usr/share; do
|
||||
plugin="$basedir/$plugin_name/$plugin_name.zsh"
|
||||
[ -f "$plugin" ] && source "$plugin" && return 0
|
||||
done
|
||||
|
@ -227,8 +232,7 @@ unset -f _source_plugin
|
|||
# POWERLEVEL
|
||||
if ! [[ $(tty) = /dev/tty* ]]
|
||||
then
|
||||
if source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme 2> /dev/null
|
||||
then
|
||||
if source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme 2> /dev/null; then
|
||||
s=' ' # fix too wide icons
|
||||
POWERLEVEL9K_MODE=nerdfont-complete
|
||||
POWERLEVEL9K_SHORTEN_STRATEGY=truncate_beginning
|
||||
|
@ -236,6 +240,7 @@ then
|
|||
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
|
||||
POWERLEVEL9K_RPROMPT_ON_NEWLINE=true
|
||||
POWERLEVEL9K_SHORTEN_DIR_LENGTH=2
|
||||
# shellcheck disable=SC2016
|
||||
POWERLEVEL9K_OS_ICON_CONTENT_EXPANSION='${P9K_CONTENT} $(whoami | grep -v "^root\$")'
|
||||
POWERLEVEL9K_OS_ICON_BACKGROUND=red
|
||||
POWERLEVEL9K_OS_ICON_FOREGROUND=white
|
||||
|
@ -310,39 +315,6 @@ switch_powerlevel_multiline_prompt(){
|
|||
zle -N 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
|
||||
[[ ! -f ~/.local/antigen.zsh ]] || source ~/.local/antigen.zsh
|
||||
|
||||
|
@ -383,7 +355,6 @@ fi
|
|||
fpath+=~/.zfunc
|
||||
|
||||
### zoxide
|
||||
# TODO: Ensure zoxide.vim is installed
|
||||
command -v zoxide > /dev/null && eval "$(zoxide init zsh)"
|
||||
|
||||
### Fig
|
||||
|
|
Loading…
Reference in a new issue