Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions .aliases
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,24 @@ alias glgcm='git log --before=$(date -d"+ 1 month" "+%Y-%m-01") --after=$(date "
alias glgt='git log --since="yesterday" --author="$(git config user.name)" --pretty=format:"%cd - %h - %s" \
--date=short --no-merges'
alias reflog='git reflog --pretty=raw | tig --pretty=raw'
alias merged='git branch --merged master | grep -v master | xargs -n 1 git branch -d && git fetch --prune'
merged() {
local base_ref

base_ref=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null ||
{ git show-ref --verify --quiet refs/remotes/origin/main && printf '%s\n' origin/main; } ||
{ git show-ref --verify --quiet refs/remotes/origin/master && printf '%s\n' origin/master; })

if [[ -z "$base_ref" ]]; then
echo "merged: unable to determine default branch (origin/HEAD not set)" >&2
return 1
fi

git branch --merged "$base_ref" |
grep -vE '^\*|^[[:space:]]*(main|master)$' |
while read -r b; do git branch -d "$b"; done

git fetch --prune
}
alias gsw='git switch'
alias gswc='git switch -c'
alias grs='git restore'
Expand All @@ -66,8 +83,8 @@ alias j='jobs -l'

# grep
alias grep='grep --color=auto'
alias egrep='egrep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='grep -E --color=auto'
alias fgrep='grep -F --color=auto'

# Quick HTTP server
alias serve='ruby -run -e httpd . -p 8080'
Expand Down Expand Up @@ -192,7 +209,6 @@ fi
# kubectl
if command -v kubectl &>/dev/null; then
alias k=kubectl
complete -F __start_kubectl k

alias netshoot='kubectl run netshoot-$(date +%s) --rm -i --tty --image nicolaka/netshoot -- /bin/bash'
fi
Expand Down
19 changes: 19 additions & 0 deletions .config/bash/completions.bash
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,22 @@ if [[ -n "${HOMEBREW_PREFIX}" ]]; then
unset _completion
fi
fi

# gh CLI completions (includes gh copilot)
if command -v gh &>/dev/null && ! complete -p gh &>/dev/null; then
eval "$(gh completion -s bash)"
fi
Comment thread
Copilot marked this conversation as resolved.

# kubectl completions (also covers the k alias defined in .aliases)
if command -v kubectl &>/dev/null; then
if ! declare -F __start_kubectl &>/dev/null; then
# shellcheck source=/dev/null
source <(kubectl completion bash)
fi
complete -o default -F __start_kubectl k
fi
Comment thread
Copilot marked this conversation as resolved.

# terraform completions
if command -v terraform &>/dev/null; then
complete -C terraform terraform
fi
15 changes: 15 additions & 0 deletions .config/bash/options.bash
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,18 @@ shopt -s extglob

# case-insensitive glob matching
shopt -s nocaseglob

# enable ** recursive globbing (e.g. ls **/*.rb)
shopt -s globstar

# update LINES/COLUMNS after each command (fixes resize artefacts)
shopt -s checkwinsize

# cd by typing a path alone, without the cd command
shopt -s autocd

# spell-correction for directory tab-completion
shopt -s dirspell

# show history expansion result in readline buffer before executing
shopt -s histverify
8 changes: 8 additions & 0 deletions .inputrc
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,11 @@ set show-all-if-ambiguous on
set show-mode-in-prompt on
set vi-cmd-mode-string \1\e[2 q\2
set vi-ins-mode-string \1\e[1 q\2

# Visual improvements
set colored-stats on
set colored-completion-prefix on
set mark-symlinked-directories on
set visible-stats on
set menu-complete-display-prefix on
set page-completions off
12 changes: 9 additions & 3 deletions .profile
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ fi
export HISTFILE="${HOME}/.bash_history"
export HISTSIZE=32768
export HISTFILESIZE=$HISTSIZE
export HISTCONTROL='ignoreboth'
export HISTCONTROL='ignoreboth:erasedups'
export HISTIGNORE='ls:cd:cd -:pwd:exit:date:*--help:vault*:*VAULT_TOKEN*:*NOMAD_TOKEN*:*CONSUL_HTTP_TOKEN*'
export HISTTIMEFORMAT='%h/%d -- %H:%M:%S '

Expand All @@ -57,7 +57,13 @@ fi
export MANPATH="$HOME/.homebrew/share/man${MANPATH+:$MANPATH}:"

# Don't clear the screen after quitting a manual page
export MANPAGER='less -X'
# Use bat for syntax-highlighted man pages when available, otherwise fall back
if command -v bat >/dev/null 2>&1; then
export MANPAGER="sh -c 'col -bx | bat -l man -p'"
export MANROFFOPT='-c'
else
export MANPAGER='less -X'
fi

# color scheme
# Keep the terminal's own TERM value (e.g. `xterm-ghostty`) when its terminfo
Expand Down Expand Up @@ -96,7 +102,7 @@ export MYSQL_PS1='(\D) \u@\h [\d] > '
# 20ms for key sequences
export KEYTIMEOUT=20

# Setting ag as the default source for fzf
# Setting rg as the default source for fzf
export FZF_DEFAULT_COMMAND='rg --files --ignore-vcs --hidden'

# fzf preview
Expand Down