Created
January 17, 2021 10:59
-
-
Save aral/cbb86225fbd98b8a0ca341bf23e7aff1 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
# Load Antigen | |
# (zsh plugin manager that can install plugins from git repositories) | |
source "/home/aral/antigen.zsh" | |
# Load oh-my-zsh. | |
antigen use oh-my-zsh | |
# Plugins from default repository | |
# (robbyrusell’s oh-my-zsh) | |
antigen bundle git | |
antigen bundle node | |
antigen bundle web-search | |
# Third-party plugins | |
antigen bundle zsh-users/zsh-autosuggestions | |
antigen bundle zsh-users/zsh-syntax-highlighting | |
# Load the spaceship theme. | |
antigen theme denysdovhan/spaceship-prompt | |
# Tell Antigen we’re done. | |
antigen apply | |
# Configure the spaceship prompt. | |
SPACESHIP_EXIT_CODE_SHOW=true | |
SPACESHIP_EXIT_CODE_SYMBOL="✘ " | |
SPACESHIP_CHAR_SYMBOL="🐵️" | |
SPACESHIP_CHAR_SUFFIX=" " | |
SPACESHIP_DIR_TRUNC=0 | |
SPACESHIP_DIR_TRUNC_REPO=false | |
SPACESHIP_PROMPT_ORDER=( | |
time # Time stamps section | |
user # Username section | |
dir # Current directory section | |
host # Hostname section | |
git # Git section (git_branch + git_status) | |
package # Package version | |
node # Node.js section | |
exec_time # Execution time | |
line_sep # Line break | |
jobs # Background jobs indicator | |
exit_code # Exit code section | |
char # Prompt character | |
) | |
SPACESHIP_GIT_PREFIX="❨git❩ " | |
SPACESHIP_GIT_STATUS_PREFIX=" /" | |
SPACESHIP_GIT_STATUS_SUFFIX="" | |
SPACESHIP_GIT_STATUS_COLOR="yellow" | |
SPACESHIP_GIT_STATUS_UNTRACKED="untracked files/" | |
SPACESHIP_GIT_STATUS_ADDED="staged changes/" | |
SPACESHIP_GIT_STATUS_MODIFIED="unstaged changes/" | |
SPACESHIP_GIT_STATUS_RENAMED="renamed files/" | |
SPACESHIP_GIT_STATUS_DELETED="deleted files/" | |
SPACESHIP_GIT_STATUS_STASHED="stashed changes/" | |
SPACESHIP_GIT_STATUS_UNMERGED="unmerged changes/" | |
SPACESHIP_GIT_STATUS_DIVERGED="working copy has diverged with remote/" | |
SPACESHIP_GIT_STATUS_AHEAD="⇡ you’re ahead of remote (push)/" | |
SPACESHIP_GIT_STATUS_BEHIND="⇣ you’re behind remote (pull)/" | |
SPACESHIP_PACKAGE_COLOR="blue" | |
SPACESHIP_PACKAGE_PREFIX="" | |
SPACESHIP_NODE_PREFIX="" | |
DEFAULT_USER="aral" # So the prompt is shorter and doesn’t show aral@dev for local sessions. | |
# Leave an empty line between the prompt and the result of the command. | |
# (Unless its a cd command or a tacit cd via use of a directory name. As these commands | |
# do not have any output, skip the extra space). | |
preexec () { | |
if [[ (! -d $1) && ($1 != cd*) ]]; then | |
echo | |
fi | |
} | |
# Preferred editor for local and remote sessions. | |
export EDITOR='nano' | |
# Setup nvm (Node version manager). | |
export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
# Add .nvmrc support | |
# (Add an .nvmrc file with a string telling nvm which node version to use and it will automatically be used.) | |
# Source: https://github.com/nvm-sh/nvm#zsh | |
autoload -U add-zsh-hook | |
load-nvmrc() { | |
local node_version="$(nvm version)" | |
local nvmrc_path="$(nvm_find_nvmrc)" | |
if [ -n "$nvmrc_path" ]; then | |
local nvmrc_node_version=$(nvm version "$(cat "${nvmrc_path}")") | |
if [ "$nvmrc_node_version" = "N/A" ]; then | |
nvm install | |
elif [ "$nvmrc_node_version" != "$node_version" ]; then | |
nvm use | |
fi | |
elif [ "$node_version" != "$(nvm version default)" ]; then | |
echo "Reverting to nvm default version" | |
nvm use default | |
fi | |
} | |
add-zsh-hook chpwd load-nvmrc | |
load-nvmrc | |
# | |
# Aliases. | |
# | |
# VSCodium | |
alias code=/usr/bin/codium | |
# Copy and paste to the clipboard by piping to these commands. | |
# (Inspired by the default behaviour in macOS.) | |
alias pbcopy='xsel --clipboard --input' | |
alias pbpaste='xsel --clipboard --output' | |
# Open files in their associated apps from Terminal. | |
alias open="xdg-open &>/dev/null " | |
# Git aliases to make git a little bit more humane for everyday use. | |
alias git-log='git log --graph --decorate --pretty=oneline --abbrev-commit' | |
alias git-log-dates='git log --graph --decorate --pretty=format:"%h [%cr] %s"' | |
alias git-tag='git tag -n' | |
alias git-undo-last-commit='git reset HEAD~' | |
# Kitty terminal’s diff tool | |
alias git-diff="git difftool --no-symlinks --dir-diff" | |
# Aliases for getting system and app information. | |
alias system-information=neofetch | |
alias disk-usage=dust | |
alias which-kernel='apt-cache policy linux-generic' | |
alias node-v8-version='node -p process.versions.v8' | |
# Make rm a little safer (have it prompt once when deleting more than | |
# three files or when deleting recursively). | |
alias rm="rm -I" | |
# A nicer ls that also shows the git status of files | |
alias l="exa -lh --git --all" | |
# A nicer ls that also shows the git status of files (but not hidden files) | |
alias ll="exa -lh --git" | |
# Same nicer ls but in tree view. | |
alias lt="exa -lh --git --all --tree" | |
# List directory, displaying octal permission codes (as used by chmod, etc.) | |
alias ls-with-octal-permissions="ls -alG | awk '{k=0;for(i=0;i<=8;i++)k+=((substr(\$1,i+2,1)~/[rwx]/)*2^(8-i));if(k)printf(\" %0o \",k);print}'" | |
fpath=($fpath "/home/aral/.zfunctions") | |
# Better find | |
alias find='fd' | |
# Enable process completion notifications for Terminal under zsh. | |
# (See https://github.com/elementary/terminal#notifications) | |
builtin . /usr/share/io.elementary.terminal/enable-zsh-completion-notifications || builtin true |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment