Last active
November 15, 2022 20:34
-
-
Save franky47/87f44cb45ae8c89f5b59 to your computer and use it in GitHub Desktop.
This file contains 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
# The following lines were added by compinstall | |
# zstyle ':completion:*:descriptions' format '%B%d%b' | |
# zstyle ':completion:*:messages' format '%d' | |
# zstyle ':completion:*:warnings' format 'No matches for: %d' | |
# zstyle ':completion:*' group-name '' | |
# zstyle ':completion:*' group-name '' | |
# zstyle ':completion:*' ignore-parents parent pwd .. directory | |
# zstyle ':completion:*' insert-unambiguous true | |
# zstyle ':completion:*' list-colors '' | |
# zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z} m:{a-zA-Z}={A-Za-z}' 'r:|[._-]=** r:|=**' 'l:|=* r:|=*' | |
# zstyle ':completion:*' max-errors 3 numeric | |
# zstyle ':completion:*' menu select=0 | |
# zstyle ':completion:*' prompt '%d)' | |
# zstyle ':completion:*' select-prompt '%SScrolling active: current selection at %p%s' | |
# zstyle ':completion:*' use-compctl false | |
# zstyle ':completion:*' verbose yes | |
# zstyle ':exec_on_xclip:*' contexts \ | |
# '0:uri_http' 'http://*' \ | |
# '1:file_gz' '(/|~)*.gz' \ | |
# '2:file' '(/|~)*' | |
# | |
# zstyle ':exec_on_xclip:*' stages '0:nox' '1:x11' | |
# zstyle ':exec_on_xclip:*' xclip 'xclip' | |
# zstyle ':exec_on_xclip:*' options '-o' | |
# zstyle ':exec_on_xclip:x11:*' operate true | |
# zstyle ':exec_on_xclip:nox:*' clearterm true | |
# if [[ -x $(which firefox) ]] ; then | |
# zstyle ':exec_on_xclip:x11:uri_http' app 'firefox -new-tab _eoxc_' | |
# else | |
# zstyle ':exec_on_xclip:x11:uri_http' app false | |
# fi | |
# | |
# | |
# zstyle ':completion:*' completer _expand _complete _correct _approximate | |
# autoload -Uz compinit | |
# compinit | |
# # End of lines added by compinstall | |
# autoload -U promptinit | |
# promptinit | |
# | |
autoload -U colors | |
colors | |
setopt autocd | |
setopt chase_links | |
autoload -U zmv | |
alias zcp='zmv -C' | |
alias zln='zmv -L' | |
# ------------------------------------------------------------------------------ | |
# History file | |
HISTFILE=~/.zsh-history | |
HISTSIZE=500 | |
SAVEHIST=50000 | |
setopt hist_ignore_all_dups \ | |
hist_reduce_blanks \ | |
hist_save_no_dups \ | |
inc_append_history \ | |
extended_history \ | |
share_history \ | |
multios | |
WATCH=all | |
LOGCHECK=20 | |
# ------------------------------------------------------------------------------ | |
# Node.js development | |
# Bun | |
export BUN_INSTALL=~/.bun | |
# FNM - https://github.com/Schniz/fnm | |
export FNM_MULTISHELL_PATH="~/Library/Caches/fnm_multishells/27467_1644943192736" | |
export FNM_VERSION_FILE_STRATEGY="local" | |
export FNM_DIR="~/Library/Application Support/fnm" | |
export FNM_LOGLEVEL="info" | |
export FNM_NODE_DIST_MIRROR="https://nodejs.org/dist" | |
export FNM_ARCH="x64" | |
# ------------------------------------------------------------------------------ | |
# Environment | |
# https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md | |
export PATH=\ | |
./.bin:\ | |
./node_modules/.bin:\ | |
~/.npm-packages/bin:\ | |
~/.cargo/bin:\ | |
~/.yarn/bin:\ | |
~/.config/yarn/global/node_modules/.bin:\ | |
$FNM_MULTISHELL_PATH/bin:\ | |
$BUN_INSTALL/bin:\ | |
$PATH | |
export EDITOR=nano | |
export SHELL=/bin/zsh | |
rehash | |
# ------------------------------------------------------------------------------ | |
# Aliases | |
alias ls='ls -F' | |
alias ll='ls -hlaGF $1' | |
alias rmds="find . -name '*.DS_Store' -type f -delete" | |
alias echon='echo -n' | |
alias cat='bat' # https://github.com/sharkdp/bat | |
alias headers='httpstat' | |
alias top='htop' | |
alias flushdns='sudo killall -HUP mDNSResponder' # 10.7+ | |
alias lns='ln -s' | |
# Git Aliases | |
alias gl='git log --graph --oneline -n 10' | |
alias gll='git log --graph -n 5' | |
alias gls='git log --oneline -n 20' | |
# Docker Helpers | |
function dll() { | |
docker container ls -a | |
echo | |
docker volume ls | |
echo | |
docker network ls | |
echo | |
docker image ls | |
} | |
function drm() { | |
echo -n "Containers: " | |
docker container prune -f | |
echo -n "Images: " | |
docker image prune -f | |
echo -n "Volumes: " | |
docker volume prune -f | |
docker network prune -f | |
} | |
alias dirm='docker image rm' | |
alias dcu='docker compose up -d' | |
alias dcd='docker compose down' | |
alias dcl='docker compose logs' | |
# Helpers | |
function mkcd() { mkdir -p "$@" && eval cd "\"\$$#\""; } | |
alias get='curl -H "Accept:application/json" -D - ' | |
function fixaudio() { ffmpeg -i "$@" -c:v copy -c:a ac3 -q:a 448 "ac3.$@" } | |
function getcert () { | |
nslookup $1 | |
(openssl s_client -showcerts -servername $1 -connect $1:443 <<< "Q" | openssl x509 -text | grep -iA2 "Validity") | |
} | |
# https://stackoverflow.com/questions/4421633/who-is-listening-on-a-given-tcp-port-on-mac-os-x | |
alias tcp='lsof -n -P -iTCP' | |
alias udp='lsof -n -P -iUDP' | |
# Crypto & data conversion | |
alias lowercase="tr '[:upper:]' '[:lower:]'" | |
alias b64="base64 | sed 's/\//_/g' | sed 's/\+/-/g'" | |
alias b64d='base64 --decode' | |
alias x2b='xxd -r -p | b64' | |
alias b2x='b64d | xxd -p' | |
alias h2b='x2b' | |
alias b2h='b2x' | |
alias sha1="shasum -a 1 | cut -d ' ' -f 1" | |
alias sha256="shasum -a 256 | cut -d ' ' -f 1" | |
alias sha512="shasum -a 512 | cut -d ' ' -f 1" | |
alias prime='openssl prime -bits 256 -generate -hex -safe' | |
alias uuid='uuidgen | lowercase' | |
## Use cache | |
# Some functions, like _apt and _dpkg, are very slow. You can use a cache in | |
# order to proxy the list of results (like the list of available debian | |
# packages) | |
zstyle ':completion:*' use-cache on | |
zstyle ':completion:*' cache-path ~/.zsh/cache | |
## From resolve's config (http://repose.cx/conf/.zshrc) | |
setopt extended_glob # Weird & wacky pattern matching - yay zsh! | |
setopt complete_in_word # Not just at the end | |
setopt always_to_end # When complete from middle, move cursor | |
setopt interactive_comments # Escape commands so I can use them later | |
setopt print_exit_value # Alert me if something's failed | |
setopt extended_history | |
autoload -U history-search-end | |
zle -N history-beginning-search-backward-end history-search-end | |
zle -N history-beginning-search-forward-end history-search-end | |
bindkey '^P' history-beginning-search-backward-end | |
bindkey '^N' history-beginning-search-forward-end | |
bindkey '^[[A' history-beginning-search-backward-end | |
bindkey '^[[B' history-beginning-search-forward-end | |
# ------------------------------------------------------------------------------ | |
# Prompt | |
setopt promptsubst | |
prompt_vcs_sep() { | |
git rev-parse --abbrev-ref HEAD 2> /dev/null | awk '{print " - "}' | |
} | |
prompt_vcs_branch() { | |
git rev-parse --abbrev-ref HEAD 2> /dev/null | awk '{print $1}' | |
} | |
prompt_vcs_status() { | |
git status --porcelain 2> /dev/null | awk ' | |
function red(str, cnt) { | |
if (cnt) printf "\033[1;31m" cnt str "\033[0m " | |
} | |
function green(str, cnt) { | |
if (cnt) printf "\033[1;32m" cnt str "\033[0m " | |
} | |
function yellow(str, cnt) { | |
if (cnt) printf "\033[1;33m" cnt str "\033[0m " | |
} | |
function blue(str, cnt) { | |
if (cnt) printf "\033[1;34m" cnt str "\033[0m " | |
} | |
function magenta(str, cnt) { | |
if (cnt) printf "\033[1;35m" cnt str "\033[0m " | |
} | |
function cyan(str, cnt) { | |
if (cnt) printf "\033[1;36m" cnt str "\033[0m " | |
} | |
$1 == "??" { u++ } # Untracked | |
$1 == "A" { a++ } # Added | |
$1 == "M" { m++ } # Modified | |
$1 == "D" { d++ } # Deleted (from tracking) | |
END { | |
printf yellow("~", m), green("+", a), red("-", d), magenta("?", u) | |
} | |
' | |
} | |
prompt_host="%{$fg[green]%}%n@%M%{$reset_color%}" | |
prompt_date="%{$fg[blue]%}%D %*%{$reset_color%}" | |
prompt_dollar="%{$fg[red]%}$ %{$reset_color%}" | |
prompt_path="%{$fg[magenta]%}%25<...<%~%<<%f%{$reset_color%}" | |
PROMPT=$'\n${prompt_host} - ${prompt_date}$(prompt_vcs_sep)%{$fg[cyan]%}$(prompt_vcs_branch)%{$reset_color%} $(prompt_vcs_status)\n${prompt_dollar}' | |
export RPROMPT="${prompt_path}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment