Skip to content

Instantly share code, notes, and snippets.

@isapir
Last active July 21, 2025 05:46
Show Gist options
  • Save isapir/8006da9414f2653676600c3ee09b8d3f to your computer and use it in GitHub Desktop.
Save isapir/8006da9414f2653676600c3ee09b8d3f to your computer and use it in GitHub Desktop.
ZSHRC Additions
[user]
name = <TODO>
email = <TODO>
[credential]
helper = cache
[alias]
mylog = "!author=$(git config --get user.name);" \
git log --all \
--author \"$author\" \
--pretty=format:\"%h %C(yellow)%as%Creset %C(green)%<(13,trunc)%an%Creset %s\"
# TODO: fix default of curuser
ulog = "!sh -c 'curuser=$(git config --get user.name) && author=${0:-$curuser} && echo $author && echo $curuser && git log --all --author \"$author\" --pretty=format:\"%h %<(13,trunc)%an %C(yellow)%as%Creset %s\"'"
glog = log --pretty=format:\"%h %C(yellow)%as%Creset %C(green)%<(13,trunc)%an%Creset %s\"
slog = log --all --pretty=format:\"%h %C(yellow)%as%Creset %C(green)%<(13,trunc)%an%Creset %s\"
tlog = log --tags --simplify-by-decoration --pretty='format:%h %C(yellow)%as%Creset %d'
find-merge = "!sh -c 'commit=$0 && branch=${1:-HEAD} && (git rev-list $commit..$branch --ancestry-path | cat -n; git rev-list $commit..$branch --first-parent | cat -n) | sort -k2 -s | uniq -f1 -d | sort -n | tail -1 | cut -f2'"
show-merge = "!sh -c 'merge=$(git find-merge $0 $1) && [ -n \"$merge\" ] && git show $merge'"
[core]
pager = less -SN
excludesfile = <TODO>/.gitignore
[filter "lfs"]
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
[remote "origin"]
tagopt = --tags
[init]
defaultBranch = main
[pull]
ff = only
## this file should be sourced in .bashrc or .zshrc
alias archivemgr='file-roller'
alias base64decode='base64 -d <<<'
alias base64encode='base64Encode' ## alias for the function below
alias cls='printf "\ec"'
alias cleanup-snaps='snap list --all | while read snapname ver rev trk pub notes; do if [[ $notes = *disabled* ]]; then sudo snap remove "$snapname" --revision="$rev"; fi; done'
alias cleanup-vscode='rm -rf .config/Code/Cache/* .config/Code/CachedData/* .config/Code/CachedExtensions/* .config/Code/CachedExtensionVSIXs/*'
alias copypwd='pwd | tr -d "\n" | pbcopy' ## copies current working directory to clipboard, requires apt install xclip
alias date-utc='date --utc -d' ## e.g. date-utc @1710720000, or date-utc 2024-03-18
alias date-epoch='date --utc +%s -d' ## e.g. date-epoch 2024-03-18
alias dell-servicetag='sudo dmidecode -s system-serial-number'
alias files='nautilus'
alias finddir="find . -type d -iname" ## e.g. finddir *phone*
alias findfiles="ag -Q"
alias fixmouseclick='sudo udevadm trigger' ## when mouse left click stops working after wakeup from sleep
alias grep='grep --color'
alias ll='ls -alhG --color=auto'
alias myip='curl -4 icanhazip.com'
alias ncdu='ncdu -e'
alias nmgui='nm-connection-editor'
alias nutty='com.github.babluboy.nutty'
alias pbcopy='xclip -selection clipboard'
alias pbpaste='xclip -selection clipboard -o'
alias sslcert-info='nmap -p 443 --script ssl-cert' ## follow by domain name
alias sudo='sudo ' ## enable aliases for sudo per https://askubuntu.com/a/22043/
alias urldecode=urlDecode
alias urlencode=urlEncode
alias uxplay='/workspace/src/UxPlay/uxplay -p 65444'
alias awswasabi='aws --profile=wasabi --endpoint-url=https://s3.wasabisys.com' ## e.g. awswasabi s3 ls
alias wasabi='aws --profile=wasabi --endpoint-url=https://s3.wasabisys.com s3' ## e.g. wasabi ls
export EDITOR=vim
export PATH=$PATH:~/.local/bin
export JAVA_HOME_21=/opt/java/zulu21.42.19-ca-jdk21.0.7-linux_x64
export JAVA_HOME=$JAVA_HOME_21
export ANT_HOME=/opt/java/apache-ant-1.10.15
export MVN_HOME=/opt/java/apache-maven-3.9.9
export PATH=$PATH:$JAVA_HOME/bin:$ANT_HOME/bin:$MVN_HOME/bin
export NODE_HOME=/opt/nodejs/node-v22.15.0-linux-x64
export PATH=$PATH:$NODE_HOME/bin
function base64Encode() {
echo -n $* | base64
}
function urlEncode() {
emulate -L zsh -o extended_glob -o no_multibyte
local RESULT
local c
for c in ${(s::)1}; do
[[ $c == [a-zA-Z0-9/_.~-] ]] || printf -v c '%%%02X' $(( #c ))
RESULT+=$c
done
echo -n $RESULT
}
function urlDecode() {
emulate -L zsh -o extended_glob
local url_encoded="${1//+/ }"
printf '%b' "${url_encoded//\%/\\x}"
}
HISTFILE=~/.zsh_history
HISTSIZE=10000
SAVEHIST=100000
## allow ? symbols in strings e.g. URLs per https://stackoverflow.com/a/42679697/968244
unsetopt no_match
## do not add to history if starts with space per https://stackoverflow.com/a/7478584/968244
setopt hist_ignore_space
## do not include duplicates in history file
setopt hist_ignore_all_dups
## https://ohmyposh.dev/ saved to ~/.local/bin
eval "$(~/.local/bin/oh-my-posh init zsh)"
source ~/.local/zsh-plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source ~/.local/zsh-plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
if [ -f ~/.setenv.sh ]; then
source ~/.setenv.sh
fi
bindkey "^A" beginning-of-line
bindkey "^E" end-of-line
bindkey "^U" backward-kill-line
bindkey "^R" history-incremental-search-backward
bindkey "^S" history-incremental-search-forward
bindkey "^[[1;5D" backward-word
bindkey "^[[1;5C" forward-word
## zsh-history-substring-search.zsh key bindings SHIFT+UP and SHIFT+DOWN
bindkey "^[[1;2A" history-substring-search-up
bindkey "^[[1;2B" history-substring-search-down
## set delimiters for CTRL+W or ALT+BACKSPACE like bash
autoload -U select-word-style
select-word-style bash
export WORDCHARS='.-'
## edit the current line in $EDITOR by clicking Ctrl+X, Ctrl+E
autoload -U edit-command-line
zle -N edit-command-line
bindkey "^X^E" edit-command-line
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment