Compare commits
10 Commits
f9ae12962d
...
6d81dd86f1
| Author | SHA1 | Date | |
|---|---|---|---|
|
6d81dd86f1
|
|||
|
4da5007ccf
|
|||
|
dbc32cf373
|
|||
|
0e54db0eae
|
|||
|
ed4e8cabe9
|
|||
|
6582a55df9
|
|||
|
b1cbd7b1fa
|
|||
|
2d371d66d0
|
|||
|
d92857428e
|
|||
|
7829980f8f
|
4
.gitignore
vendored
4
.gitignore
vendored
@@ -8,7 +8,6 @@
|
|||||||
|
|
||||||
# allow some stuff to be pushed
|
# allow some stuff to be pushed
|
||||||
!alacritty
|
!alacritty
|
||||||
!.pyenv
|
|
||||||
|
|
||||||
# zsh
|
# zsh
|
||||||
!zsh
|
!zsh
|
||||||
@@ -16,12 +15,9 @@ zsh/*
|
|||||||
!zsh/.zshrc
|
!zsh/.zshrc
|
||||||
!zsh/.zshenv
|
!zsh/.zshenv
|
||||||
!zsh/.zprofile
|
!zsh/.zprofile
|
||||||
!zsh/.zsh_plugins*.txt
|
|
||||||
!zsh/scripts.zsh
|
!zsh/scripts.zsh
|
||||||
!zsh/aliases.zsh
|
!zsh/aliases.zsh
|
||||||
!zsh/completions/.keep
|
|
||||||
!zsh/ssh-menu
|
!zsh/ssh-menu
|
||||||
!zsh/get-dump
|
|
||||||
|
|
||||||
# starship
|
# starship
|
||||||
!starship
|
!starship
|
||||||
|
|||||||
@@ -1,5 +0,0 @@
|
|||||||
# Neovim should be able to run anywhere
|
|
||||||
pynvim
|
|
||||||
|
|
||||||
# Upgrade pip while we're at it.
|
|
||||||
pip
|
|
||||||
@@ -1 +1,5 @@
|
|||||||
|
path=(
|
||||||
|
"$HOME/.local/bin"
|
||||||
|
"$GOPATH/bin"
|
||||||
|
$path
|
||||||
|
)
|
||||||
|
|||||||
@@ -1,11 +0,0 @@
|
|||||||
# set up Zsh completions with plugins
|
|
||||||
# mattmc3/ez-compinit
|
|
||||||
zsh-users/zsh-completions kind:fpath path:src
|
|
||||||
|
|
||||||
# frameworks like oh-my-zsh are supported
|
|
||||||
getantidote/use-omz # handle OMZ dependencies
|
|
||||||
ohmyzsh/ohmyzsh path:lib # load OMZ's library
|
|
||||||
ohmyzsh/ohmyzsh path:plugins/git
|
|
||||||
|
|
||||||
# popular fish-like plugins
|
|
||||||
zsh-users/zsh-autosuggestions
|
|
||||||
32
zsh/.zshenv
32
zsh/.zshenv
@@ -4,11 +4,8 @@ export XDG_CACHE_HOME="$HOME/.cache"
|
|||||||
export XDG_DATA_HOME="$HOME/.local/share"
|
export XDG_DATA_HOME="$HOME/.local/share"
|
||||||
export XDG_STATE_HOME="$HOME/.local/state"
|
export XDG_STATE_HOME="$HOME/.local/state"
|
||||||
|
|
||||||
# ~/.local/bin
|
# deduplicate path
|
||||||
export PATH="$HOME/.local/bin:$PATH"
|
typeset -U path
|
||||||
|
|
||||||
# language environment
|
|
||||||
export LANG=en_US.UTF-8
|
|
||||||
|
|
||||||
# editor
|
# editor
|
||||||
export EDITOR=nvim
|
export EDITOR=nvim
|
||||||
@@ -16,35 +13,12 @@ export EDITOR=nvim
|
|||||||
# go
|
# go
|
||||||
export GOPATH="$XDG_DATA_HOME/go"
|
export GOPATH="$XDG_DATA_HOME/go"
|
||||||
export GOMODCACHE="$XDG_CACHE_HOME/go/mod"
|
export GOMODCACHE="$XDG_CACHE_HOME/go/mod"
|
||||||
export PATH="$GOPATH/bin:$PATH"
|
|
||||||
|
|
||||||
# ggman
|
# ggman
|
||||||
export GGROOT="$HOME/git"
|
export GGROOT="$HOME/git"
|
||||||
|
|
||||||
# neovim
|
|
||||||
export PATH="$XDG_DATA_HOME/neovim/bin:$PATH"
|
|
||||||
|
|
||||||
# pyenv
|
|
||||||
export PYENV_ROOT="$XDG_DATA_HOME/.pyenv"
|
|
||||||
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
|
|
||||||
|
|
||||||
# pyenv-virtualenv
|
|
||||||
# leave python promt to starship
|
|
||||||
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
|
|
||||||
|
|
||||||
# poetry
|
|
||||||
export POETRY_HOME="$XDG_DATA_HOME/poetry"
|
|
||||||
command -v poetry >/dev/null || export PATH="$POETRY_HOME/bin:$PATH"
|
|
||||||
|
|
||||||
# gnupg
|
|
||||||
export GPG_TTY=$(tty)
|
|
||||||
|
|
||||||
# aflabs
|
|
||||||
export USER_UID=$(id -u)
|
|
||||||
export USER_GID=$(id -g)
|
|
||||||
|
|
||||||
# name
|
# name
|
||||||
export NAME="Matej Janežič"
|
export NAME="Matej Janežič"
|
||||||
|
|
||||||
# starship nest config into a folder, default is ~/.config/startship.toml
|
# starship nest config into a folder, default is ~/.config/starship.toml
|
||||||
export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/config.toml"
|
export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/config.toml"
|
||||||
|
|||||||
74
zsh/.zshrc
74
zsh/.zshrc
@@ -1,31 +1,69 @@
|
|||||||
# zsh history file
|
# shell options
|
||||||
export HISTFILE="$XDG_STATE_HOME/zsh/history"
|
unsetopt autocd # don't cd into directories by name
|
||||||
export HISTSIZE=100
|
setopt NO_BEEP # no terminal bell
|
||||||
|
setopt AUTO_PUSHD # cd pushes to directory stack
|
||||||
|
setopt PUSHD_IGNORE_DUPS # no duplicates in directory stack
|
||||||
|
setopt EXTENDED_GLOB # enable extended glob operators (#, ~, ^)
|
||||||
|
|
||||||
## pre plugin load
|
# history
|
||||||
# nvm
|
HISTFILE="$XDG_STATE_HOME/zsh/history"
|
||||||
export NVM_COMPLETION=true
|
HISTSIZE=10000
|
||||||
# zsh autosugestions
|
SAVEHIST=10000
|
||||||
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ffffff,bg=cyan,bold,underline"
|
setopt HIST_IGNORE_DUPS # skip consecutive duplicates
|
||||||
|
setopt HIST_IGNORE_SPACE # skip commands starting with space
|
||||||
|
setopt SHARE_HISTORY # share history across sessions
|
||||||
|
setopt HIST_REDUCE_BLANKS # strip extra whitespace
|
||||||
|
|
||||||
# source antidote
|
# plugins
|
||||||
source $ZDOTDIR/.antidote/antidote.zsh
|
local _plugins="$XDG_DATA_HOME/zsh/plugins"
|
||||||
antidote load
|
local _stamp="$XDG_CACHE_HOME/zsh/plugins-updated"
|
||||||
|
local _repos=(
|
||||||
|
"https://github.com/zsh-users/zsh-completions"
|
||||||
|
"https://github.com/zsh-users/zsh-autosuggestions"
|
||||||
|
)
|
||||||
|
local _needs_update=0
|
||||||
|
|
||||||
unsetopt autocd
|
if [[ ! -f "$_stamp" ]] || [[ -n $_stamp(#qN.mh+168) ]]; then
|
||||||
|
mkdir -p "${_stamp:h}"
|
||||||
|
touch "$_stamp"
|
||||||
|
_needs_update=1
|
||||||
|
fi
|
||||||
|
|
||||||
# ggman
|
for _repo in $_repos; do
|
||||||
eval "$(ggman shellrc)"
|
if [[ ! -d "$_plugins/${_repo:t}" ]]; then
|
||||||
|
git clone "$_repo" "$_plugins/${_repo:t}"
|
||||||
|
elif (( _needs_update )); then
|
||||||
|
git -C "$_plugins/${_repo:t}" pull --quiet &
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
(( _needs_update )) && wait
|
||||||
|
|
||||||
# custom functions and aliases
|
fpath=("$_plugins/zsh-completions/src" $fpath)
|
||||||
|
ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ffffff,bg=cyan,bold,underline"
|
||||||
|
source "$_plugins/zsh-autosuggestions/zsh-autosuggestions.zsh"
|
||||||
|
|
||||||
|
# aliases and functions
|
||||||
source "$ZDOTDIR/aliases.zsh"
|
source "$ZDOTDIR/aliases.zsh"
|
||||||
source "$ZDOTDIR/scripts.zsh"
|
source "$ZDOTDIR/scripts.zsh"
|
||||||
|
|
||||||
# completion
|
# completion
|
||||||
fpath=($ZDOTDIR/completions $fpath)
|
fpath=("$XDG_DATA_HOME/zsh/completions" $fpath)
|
||||||
autoload -Uz compinit
|
autoload -Uz compinit
|
||||||
compinit -d $XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION
|
# only regenerate dump once per day
|
||||||
zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh/zcompcache
|
local _zcompdump="$XDG_CACHE_HOME/zsh/zcompdump-$ZSH_VERSION"
|
||||||
|
if [[ -n $_zcompdump(#qN.mh+24) ]]; then
|
||||||
|
compinit -d "$_zcompdump"
|
||||||
|
else
|
||||||
|
compinit -C -d "$_zcompdump"
|
||||||
|
fi
|
||||||
|
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
|
||||||
|
zstyle ':completion:*' menu select
|
||||||
|
zstyle ':completion:*' matcher-list 'm:{a-z}={A-Z}'
|
||||||
|
|
||||||
|
# tool hooks
|
||||||
|
eval "$(ggman shellrc)"
|
||||||
eval "$(starship init zsh)"
|
eval "$(starship init zsh)"
|
||||||
eval "$(direnv hook zsh)"
|
eval "$(direnv hook zsh)"
|
||||||
|
|
||||||
|
# gnupg
|
||||||
|
export GPG_TTY=$(tty)
|
||||||
|
|||||||
@@ -10,13 +10,59 @@ alias dp="docker ps --format 'table {{.Names}}\t{{.Ports}}'"
|
|||||||
alias dcp="docker compose ps --format 'table {{.Name}}\t{{.Ports}}'"
|
alias dcp="docker compose ps --format 'table {{.Name}}\t{{.Ports}}'"
|
||||||
|
|
||||||
# navigation
|
# navigation
|
||||||
alias cdgit="cd $GGROOT"
|
alias cdgit='cd $GGROOT'
|
||||||
|
|
||||||
# git
|
# git status/diff
|
||||||
alias gpo="git push origin"
|
alias gst="git status"
|
||||||
alias gros="git reset origin/$(git_current_branch) --soft"
|
alias gd="git diff"
|
||||||
alias gcan="git commit -v --amend --no-edit"
|
alias gds="git diff --staged"
|
||||||
|
alias gdup="git diff @{upstream}"
|
||||||
|
alias glog="git log --oneline --decorate --graph"
|
||||||
|
alias gloga="git log --oneline --decorate --graph --all"
|
||||||
alias glogaa="git log --oneline --graph --all --pretty=format:\"%C(auto)%h %C(blue)(%aL/%cL)%C(auto)%(decorate) %s%Creset\""
|
alias glogaa="git log --oneline --graph --all --pretty=format:\"%C(auto)%h %C(blue)(%aL/%cL)%C(auto)%(decorate) %s%Creset\""
|
||||||
|
|
||||||
|
# git staging/commit
|
||||||
|
alias ga="git add"
|
||||||
|
alias gc="git commit -v"
|
||||||
|
alias gc!="git commit -v --amend"
|
||||||
|
alias gcan="git commit -v --amend --no-edit"
|
||||||
|
alias gcan!="git commit -v --all --no-edit --amend"
|
||||||
|
alias grs="git restore"
|
||||||
|
|
||||||
|
# git branch/checkout
|
||||||
|
alias gb="git branch"
|
||||||
|
alias gco="git checkout"
|
||||||
|
alias gcm='git checkout $(git_main_branch)'
|
||||||
|
alias gsw="git switch"
|
||||||
|
|
||||||
|
# git fetch/pull/push
|
||||||
|
alias gfa="git fetch --all --prune"
|
||||||
|
alias gl="git pull"
|
||||||
|
alias gp="git push"
|
||||||
|
alias gpf="git push --force-with-lease"
|
||||||
|
alias gpf!="git push --force"
|
||||||
|
alias gpo="git push origin"
|
||||||
|
|
||||||
|
# git rebase
|
||||||
|
alias grb="git rebase"
|
||||||
|
alias grba="git rebase --abort"
|
||||||
|
alias grbc="git rebase --continue"
|
||||||
|
alias grbi="git rebase -i"
|
||||||
|
grbm() { git rebase "$(git_main_branch)" }
|
||||||
|
|
||||||
|
# git merge
|
||||||
|
alias gm="git merge"
|
||||||
|
alias gma="git merge --abort"
|
||||||
|
alias gmc="git merge --continue"
|
||||||
|
|
||||||
|
# git cherry-pick
|
||||||
|
alias gcp="git cherry-pick"
|
||||||
|
alias gcpa="git cherry-pick --abort"
|
||||||
|
alias gcpc="git cherry-pick --continue"
|
||||||
|
|
||||||
|
# git stash/reset
|
||||||
|
alias gstp="git stash pop"
|
||||||
|
gros() { git reset "origin/$(git_current_branch)" --soft }
|
||||||
|
|
||||||
# ruff
|
# ruff
|
||||||
alias ruffme="ruff check --fix && ruff format"
|
alias ruffme="ruff check --fix && ruff format"
|
||||||
|
|||||||
51
zsh/get-dump
51
zsh/get-dump
@@ -1,51 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
function get-dump {
|
|
||||||
if [[ -z $1 ]]; then
|
|
||||||
host="$(rg -N --no-heading 'Host .*' ~/.ssh \
|
|
||||||
| sed 's/Host \(.*\)/\1/' \
|
|
||||||
| fzf --cycle \
|
|
||||||
--bind 'tab:toggle-up,btab:toggle-down' \
|
|
||||||
--delimiter ':' \
|
|
||||||
--with-nth 2 \
|
|
||||||
--header "Navigate with ARROW KEYS or TAB/S-TAB. Select with ENTER." \
|
|
||||||
--border "double" \
|
|
||||||
--border-label "get-dump" \
|
|
||||||
--ansi \
|
|
||||||
--highlight-line \
|
|
||||||
| cut -d ":" -f2
|
|
||||||
)"
|
|
||||||
if [[ -z $host ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
host=$1
|
|
||||||
fi
|
|
||||||
|
|
||||||
selected=$(ssh "$host" docker ps --format "{{.Names}}" \
|
|
||||||
| fzf --cycle \
|
|
||||||
--bind 'tab:toggle-up,btab:toggle-down' \
|
|
||||||
--header "Navigate with ARROW KEYS or TAB/S-TAB. Select with ENTER." \
|
|
||||||
--border "double" \
|
|
||||||
--border-label "get-dump" \
|
|
||||||
--ansi \
|
|
||||||
--highlight-line \
|
|
||||||
)
|
|
||||||
|
|
||||||
if [[ -z $selected ]]; then
|
|
||||||
echo "not provided"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ! [[ -d "./dumps" ]]; then
|
|
||||||
mkdir "./dumps"
|
|
||||||
fi
|
|
||||||
|
|
||||||
location="./dumps/${host}_${selected}_$(date +'%s')"
|
|
||||||
|
|
||||||
echo "dumping to $location"
|
|
||||||
|
|
||||||
ssh "$host" docker exec "$selected" pg_dump -U db --format=c db >"$location"
|
|
||||||
}
|
|
||||||
|
|
||||||
get-dump "$@"
|
|
||||||
@@ -1,10 +1,28 @@
|
|||||||
|
# git helpers for aliases
|
||||||
|
function git_current_branch {
|
||||||
|
command git rev-parse --abbrev-ref HEAD 2>/dev/null
|
||||||
|
}
|
||||||
|
|
||||||
|
function git_main_branch {
|
||||||
|
command git rev-parse --git-dir &>/dev/null || return
|
||||||
|
local ref
|
||||||
|
for ref in refs/{heads,remotes/{origin,upstream}}/{main,master,trunk}; do
|
||||||
|
if command git show-ref -q --verify "$ref"; then
|
||||||
|
echo ${ref:t}
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo main
|
||||||
|
}
|
||||||
|
|
||||||
function tmux_attach {
|
function tmux_attach {
|
||||||
|
local tmux_running
|
||||||
tmux_running=$(pgrep tmux)
|
tmux_running=$(pgrep tmux)
|
||||||
|
|
||||||
if ! [[ -z ${TMUX} ]]; then
|
if [[ -n ${TMUX} ]]; then
|
||||||
echo "already attached; refreshing env"
|
echo "already attached; refreshing env"
|
||||||
source <(tmux show-environment | sed -n 's/^\(.*\)=\(.*\)$/export \1="\2"/p')
|
source <(tmux show-environment | sed -n 's/^\(.*\)=\(.*\)$/export \1="\2"/p')
|
||||||
return 1
|
return 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $tmux_running ]]; then
|
if [[ -z $tmux_running ]]; then
|
||||||
|
|||||||
Reference in New Issue
Block a user