Last active
December 4, 2024 04:53
-
-
Save tvandoren/892c46d0dd1f2fd09e34690580abeaf3 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# set some history options | |
setopt appendhistory | |
setopt sharehistory | |
setopt incappendhistory | |
setopt hist_ignore_all_dups | |
setopt hist_save_no_dups | |
setopt hist_ignore_dups | |
setopt hist_find_no_dups | |
# case insensitive completion | |
zstyle ':completion:*' matcher-list 'm:{[:lower:][:upper:]}={[:upper:][:lower:]}' 'r:|=*' 'l:|=* r:|=*' | |
# up/down autocomplete | |
autoload -U up-line-or-beginning-search | |
autoload -U down-line-or-beginning-search | |
zle -N up-line-or-beginning-search | |
zle -N down-line-or-beginning-search | |
bindkey "$terminfo[kcuu1]" up-line-or-beginning-search | |
bindkey "$terminfo[kcud1]" down-line-or-beginning-search | |
# directory traversal | |
setopt auto_cd | |
setopt auto_pushd | |
setopt pushd_ignore_dups | |
setopt pushdminus | |
alias -g ...='../..' | |
alias -g ....='../../..' | |
alias -g .....='../../../..' | |
alias -g ......='../../../../..' | |
unsetopt beep | |
# various setup stuff | |
eval "$(starship init zsh)" | |
eval "$(/home/trevor/.local/bin/mise activate zsh)" | |
source /usr/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh | |
source ~/.zsh/zsh-autosuggestions/zsh-autosuggestions.zsh | |
# git | |
alias co="git checkout" | |
deletemerged() { | |
merged_branches=$(git branch --merged) | |
branches=$(git branch -vv | grep ': gone]' | grep -v '\*' | awk '{print $1}') | |
if [ -z "$branches" ]; then | |
echo "No branches to delete" | |
return | |
fi | |
echo "$branches" | while IFS= read -r branch; do | |
if echo "$merged_branches" | grep -q "$branch"; then | |
echo "Deleting merged branch: $branch" | |
git branch -d "$branch" | |
else | |
echo "Branch $branch is not fully merged." | |
echo -n "Do you want to delete it? (Y/n): " | |
# Redirect read to explicitly take input from /dev/tty, the controlling terminal (zsh subshell doesn't like reading in a while loop?) | |
if read -r REPLY </dev/tty; then | |
echo | |
if [[ ! $REPLY =~ ^[Nn]$ ]]; then | |
git branch -D "$branch" | |
else | |
echo "Skipped deleting $branch" | |
fi | |
else | |
echo "Failed to read input." | |
fi | |
fi | |
done | |
} | |
getlate () { co $1 && git pull -p && deletemerged } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment