Uses
Created at
||Updated at
Shell
Some CLI tools I use daily are
- bat - Better
cat, supports syntax highlighting - lsd - Better
ls - jq - JSON processor
- killport - Kill a process running on a specific port
- gh - The Github CLI
- mise - Install various versions of the same tool
- atuin - Shell history
- starship - Custom shell prompt
.zshrc
# Setup history
HISTFILE="$HOME/.zsh_history"
HISTSIZE=10000000
SAVEHIST=10000000
HISTORY_IGNORE="(l|ls|cd|pwd)*"
# https://zsh.sourceforge.io/Doc/Release/Options.html (16.2.4 History)
setopt EXTENDED_HISTORY # Write the history file in the ':start:elapsed;command' format.
setopt SHARE_HISTORY # Share history between all sessions.
setopt HIST_IGNORE_DUPS # Do not record an event that was just recorded again.
setopt HIST_IGNORE_ALL_DUPS # Delete an old recorded event if a new event is a duplicate.
setopt HIST_SAVE_NO_DUPS # Do not write a duplicate event to the history file.
setopt HIST_VERIFY # Do not execute immediately upon history expansion.
setopt INC_APPEND_HISTORY_TIME # append to history file with timestamps
setopt HIST_NO_STORE # Don't store history commands
setopt HIST_REDUCE_BLANKS # Remove superfluous blanks from each command line being added to the history.
# Path to your oh-my-zsh installation
export ZSH="$HOME/.oh-my-zsh"
zstyle ':omz:update' mode reminder # Remind me to update when it's time
zstyle ':omz:update' frequency 14 # Once every 14 days
# Disable auto-setting terminal title
DISABLE_AUTO_TITLE="true"
# homebrew
eval "$(/opt/homebrew/bin/brew shellenv)"
source $ZSH/oh-my-zsh.sh
# Add deno completions to search path
if [[ ":$FPATH:" != *":~/completions:"* ]]; then export FPATH="~/completions:$FPATH"; fi
source ~/.deno/env
# Preferred editor for local and remote sessions
export EDITOR='nvim'
# Enables interactive shell comments i.e. comment lines starting with #
setopt interactivecomments
# Aliases
alias ls="lsd"
alias l="ls -l"
alias sort_size="du -hcd1 | sort -hr"
# Sign commits with GPG
# https://docs.github.com/en/authentication/managing-commit-signature-verification/telling-git-about-your-signing-key
export GPG_TTY=$(tty)
# Make local node_modules binaries easier to run by adding them to the PATH
LOCAL_NODE_MODULES="./node_modules/.bin"
# Go binaries
GO_BINARIES="$HOME/go/bin"
BINARY_PATHS=(
$LOCAL_NODE_MODULES
$GO_BINARIES
)
# Concatenate and export binary paths
export PATH="${(j/:/)BINARY_PATHS}:$PATH"
# Init staship
eval "$(starship init zsh)"
# Init atuin
eval "$(atuin init zsh)"
# zinit
source "$HOME/.local/share/zinit/zinit.git/zinit.zsh"
autoload -Uz _zinit
# load plugins with zinit
zinit snippet OMZP::git
zinit light zsh-users/zsh-autosuggestions
zinit light zsh-users/zsh-syntax-highlighting
eval "$(mise activate zsh)"
# On setup
# mise settings add idiomatic_version_file_enable_tools node
# Set language to English
export LANG="en_US.UTF-8"
git
~/.gitconfig
[alias]
# one character for easier use of this frequent used command
s = status
# prettier git log
lg = log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
# find the remote urls of a repository
gh-url = remote get-url --all origin
# fetch everything
sync = fetch --all --tags --prune
# some rough git statistics for your user in a defined time period
stats = "!git log --author=$(git config user.email) --since=\"$SINCE:-1 year ago\" --until=\"$UNTIL:-now\" --pretty=tformat: --numstat | egrep -v '__snapshots__|.json|.yml' | awk '{ add += $1; subs += $2; loc += $1 - $2 } END { printf \"Added lines\\t%s\\nRemoved lines\\t%s\\nTotal lines\\t%s\\n\", add, subs, loc }'"
# remove all branches that are already merged into master
remove-gone-branches = "!git branch -vv | awk '/: gone]/{print $1}' | xargs git branch -D"
# commits not in master
compare-with-master = lg origin/master..HEAD
# easier rebase a branch
rebase-onto = "!f() { git rebase --onto=\"$1\" $(git merge-base --fork-point \"$1\"); }; f"
# show diff using https://github.com/wilfred/difftastic
show-ext = show --ext-diff
# get the latest tag
latest-tag = !git fetch --quiet --all && git describe --tags --abbrev=0
# stash all except a specific path
stash-excluding = "!f() { git stash push --include-untracked -- :!$1; }; f"
# git blame ignoring whitespace and moving
deep-blame = blame -w -C
[core]
# silence pager if output fits on one screen
pager = less -quit-if-one-screen --no-init
[init]
# use main as default branch
defaultBranch = main
[push]
# no need to manually set upstream
autoSetupRemote = true
# also push tags by default
followTags = true
[pager]
# do not paginate branch output
branch = false
[diff]
# use https://github.com/wilfred/difftastic for prettier git diff
external = difft
[rebase]
# auto stash changes before rebase
autoStash = true
[rerere]
# enable rerere for easier conflict resolution
enabled = true
[help]
# prompt for a similar command when you make a typo
autocorrect = prompt
[branch]
# sort branch output by committer date
sort = -committerdate
[includeIf "gitdir:~/personal/"]
# include another gitconfig for personal projects
path = "~/.personal_gitconfig"