Last active
June 15, 2022 06:45
-
-
Save didinele/b77c46c0d17d95facb0f9827503df808 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
# Ghost character fix | |
export LC_ALL="en_US.UTF-8" | |
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib" | |
export XDG_CONFIG_HOME="$HOME/.config" | |
export KEYTIMEOUT=1 | |
export GPG_TTY=$(tty) | |
export CODE=$HOME/Documents/Code | |
export PNPM_HOME=/home/didinele/.local/share/pnpm | |
export PATH="$PATH:$HOME/.local:$PATH:$HOME/.cargo/bin:$PATH:$HOME/opt/cross/bin:$PATH:$PATH:$HOME/.local/share/pnpm" | |
. "$HOME/.cargo/env" |
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
setopt histignorealldups | |
setopt interactivecomments | |
setopt menucomplete | |
setopt promptsubst | |
setopt sharehistory | |
setopt no_nomatch | |
setopt no_nullglob | |
alias code='code-insiders' | |
# Ls | |
alias ls='exa -al --color=always --group-directories-first' # general listing | |
alias la='exa -a --color=always --group-directories-first' # simple listing | |
alias ll='exa -l --color=always --group-directories-first' # hide secret files | |
alias lt='exa -aT --color=always --group-directories-first' # tree listing | |
# Utils | |
alias cp='cp -i' | |
alias grep='grep --color=auto' | |
alias diff='diff --color=auto' | |
# Managing dotfiles (https://github.com/didinele/dotfiles) | |
alias config="/usr/bin/git --git-dir=$HOME/dotfiles --work-tree=$HOME" | |
# `mkdir` and `cd` combined. | |
mkcd() { | |
mkdir "$1" | |
cd "$1" | |
} | |
print_prompt_git_info() { | |
local branch_or_tag="$(git symbolic-ref --short HEAD 2> /dev/null || \ | |
git describe --exact-match HEAD 2> /dev/null)" | |
if [ -n "$branch_or_tag" ]; then | |
# Print working branch or tag | |
echo -n "on %B%F{magenta}$branch_or_tag%f%b" | |
local changes="$(git status --porcelain | wc -l)" | |
if [ "$changes" -ne "0" ]; then | |
# Indicator for uncommitted changes | |
echo -n " [%B%F{yellow}*%f%b]" | |
fi | |
echo -n " " | |
fi | |
} | |
get_npm_version() { | |
echo $([ -e package.json ] && awk -F \" '/"version": ".+"/ { print $4; exit; }' package.json || echo -n) | |
} | |
print_prompt_npm_info() { | |
local npm_version=$(get_npm_version) | |
while [ ! $npm_version ]; do | |
[ $PWD == '/' ] && break | |
cd .. | |
npm_version=$(get_npm_version) | |
done | |
if [ $npm_version ]; then | |
echo -n "is %B%F{yellow}v$npm_version%f%b " | |
fi | |
} | |
print_prompt_symbol() { | |
# Set prompt arrow color based on the exit code returned by the last command | |
if [ "$1" -eq "0" ]; then | |
echo -n "%B%F{green}" | |
else | |
echo -n "%B%F{red}" | |
fi | |
echo -n "\n➜ %f%b" | |
} | |
print_prompt() { | |
# Save last command's exit code | |
local exit_code="$?" | |
# Print current user | |
echo -n "%B%F{cyan}$USER%f%b " | |
# Print hostname | |
echo -n "at %B%F{green}$(cat /etc/hostname)%f%b " | |
# Print working directory | |
echo -n "in %B%F{cyan}%~%f%b " | |
print_prompt_git_info | |
print_prompt_npm_info | |
print_prompt_symbol "$exit_code" | |
} | |
PROMPT='$(print_prompt)' | |
precmd() { | |
RPROMPT='' | |
} | |
# Keybindings | |
bindkey "^[[H" beginning-of-line # Home | |
bindkey "^[[F" end-of-line # End | |
bindkey "^[[3~" delete-char # Delete | |
bindkey "^[[1;5C" forward-word # Ctrl + Left arrow | |
bindkey "^[[1;5D" backward-word # Ctrl + Right arrow | |
bindkey "^H" backward-kill-word # Ctrl + Backspace | |
# Keep 50000 lines of history within the shell and save it to ~/.zsh_history | |
HISTSIZE=50000 | |
SAVEHIST=50000 | |
HISTFILE=~/.zsh_history | |
# Use modern completion system | |
autoload -Uz compinit | |
compinit | |
zstyle ':completion:*' auto-description 'specify: %d' | |
zstyle ':completion:*' format '%B%F{blue}Completing %d%b%f' | |
zstyle ':completion:*' group-name '' | |
zstyle ':completion:*' menu select | |
zstyle ':completion:*' menu select=5 | |
zstyle ':completion:*:descriptions' format "%B%d%b" | |
eval "$(dircolors -b)" | |
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS} | |
zstyle ':completion:*' list-colors '' | |
zstyle ':completion:*' list-prompt '%B%F{blue}At %p: Hit TAB for more, or the character to insert%b%f' | |
zstyle ':completion:*' matcher-list '' 'm:{a-z}={A-Z}' 'm:{a-zA-Z}={A-Za-z}' 'r:|[._-]=* r:|=* l:|=*' | |
zstyle ':completion:*' select-prompt '%B%F{blue}Scrolling active: current selection at %p%b%f' | |
zstyle ':completion:*' use-compctl true | |
zstyle ':completion:*' verbose true | |
zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31' | |
zstyle ':completion:*:kill:*' command 'ps -u $USER -o pid,%cpu,tty,cputime,cmd' | |
# Plugins | |
source $HOME/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh | |
source $HOME/.zsh/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
# nvm | |
source ~/.zsh-nvm/zsh-nvm.plugin.zsh | |
la |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment