261 lines
8.4 KiB
Fish
261 lines
8.4 KiB
Fish
set PATH {$HOME}/.nix-profile/bin {$HOME}/.cargo/bin {$HOME}/.cabal/bin $PATH
|
|
set -gx TERM xterm-kitty
|
|
set -gx NIX_PATH {$HOME}/.nix-defexpr/channels
|
|
|
|
export EDITOR='nvim'
|
|
export BROWSER='firefox'
|
|
export MANPAGER='nvim +Man!'
|
|
export NIX_SSL_CERT_FILE='/etc/ssl/certs/ca-certificates.crt'
|
|
export MOZ_ENABLE_WAYLAND=1
|
|
|
|
alias b="cd .."
|
|
alias c="clear"
|
|
alias v="nvim"
|
|
alias tksa="tmux kill-session -a"
|
|
alias tks="tmux kill-server"
|
|
alias tat="tmux attach -t "
|
|
alias tls="tmux ls"
|
|
alias vf="v (fzf)"
|
|
alias cs="cscope -bqR"
|
|
alias cat="bat"
|
|
alias t="tokei ."
|
|
alias gst="gst-inspect-1.0"
|
|
alias gsl="gst-launch-1.0"
|
|
alias sds="systemctl status "
|
|
alias sde="systemctl enable "
|
|
alias sdd="systemctl disable "
|
|
alias lg="lazygit -ucd ~/.config/lazygit"
|
|
|
|
# Git helpers
|
|
alias vg="vgrep"
|
|
alias vs="vgrep -s"
|
|
|
|
# Branch (b)
|
|
alias gb='git branch'
|
|
alias gba='git branch --all --verbose'
|
|
alias gbc='git checkout -b'
|
|
alias gbd='git branch --delete'
|
|
alias gbD='git branch --delete --force'
|
|
alias gbl='git branch --verbose'
|
|
alias gbL='git branch --all --verbose'
|
|
alias gbm='git branch --move'
|
|
alias gbM='git branch --move --force'
|
|
alias gbr='git branch --move'
|
|
alias gbR='git branch --move --force'
|
|
alias gbs='git show-branch'
|
|
alias gbS='git show-branch --all'
|
|
alias gbv='git branch --verbose'
|
|
alias gbV='git branch --verbose --verbose'
|
|
alias gbx='git branch --delete'
|
|
alias gbX='git branch --delete --force'
|
|
|
|
# Commit (c)
|
|
alias gc='git commit --verbose'
|
|
alias gca='git commit --verbose --all'
|
|
alias gcm='git commit --message'
|
|
alias gcS='git commit -s --verbose'
|
|
alias gcSa='git commit -s --verbose --all'
|
|
alias gcSm='git commit -s --message'
|
|
alias gcam='git commit --all --message'
|
|
alias gco='git checkout'
|
|
alias gcO='git checkout --patch'
|
|
alias gcf='git commit --amend --reuse-message HEAD'
|
|
alias gcSf='git commit -S --amend --reuse-message HEAD'
|
|
alias gcF='git commit --verbose --amend'
|
|
alias gcSF='git commit -S --verbose --amend'
|
|
alias gcp='git cherry-pick --ff'
|
|
alias gcP='git cherry-pick --no-commit'
|
|
alias gcr='git revert'
|
|
alias gcR='git reset HEAD^'
|
|
alias gcs='git show'
|
|
alias gcsS='git show --pretty=short --show-signature'
|
|
alias gcl='git-commit-lost'
|
|
alias gcy='git cherry -v --abbrev'
|
|
alias gcY='git cherry -v'
|
|
|
|
# Conflict (C)
|
|
alias gCl='git --no-pager diff --name-only --diff-filter=U'
|
|
alias gCa='git add (gCl)'
|
|
alias gCe='git mergetool (gCl)'
|
|
alias gCo='git checkout --ours --'
|
|
alias gCO='gCo (gCl)'
|
|
alias gCt='git checkout --theirs --'
|
|
alias gCT='gCt (gCl)'
|
|
|
|
# Data (d)
|
|
alias gd='git ls-files'
|
|
alias gdc='git ls-files --cached'
|
|
alias gdx='git ls-files --deleted'
|
|
alias gdm='git ls-files --modified'
|
|
alias gdu='git ls-files --other --exclude-standard'
|
|
alias gdk='git ls-files --killed'
|
|
|
|
# Fetch (f)
|
|
alias gf='git fetch'
|
|
alias gfa='git fetch --all'
|
|
alias gfc='git clone'
|
|
alias gfcr='git clone --recurse-submodules'
|
|
alias gfm='git pull'
|
|
alias gfr='git pull --rebase'
|
|
|
|
# Grep (g)
|
|
alias gg='git grep'
|
|
alias ggi='git grep --ignore-case'
|
|
alias ggl='git grep --files-with-matches'
|
|
alias ggL='git grep --files-without-matches'
|
|
alias ggv='git grep --invert-match'
|
|
alias ggw='git grep --word-regexp'
|
|
|
|
# Index (i)
|
|
alias gia='git add'
|
|
alias giA='git add --patch'
|
|
alias giu='git add --update'
|
|
alias gid='git diff --no-ext-diff --cached'
|
|
alias giD='git diff --no-ext-diff --cached --word-diff'
|
|
alias gii='git update-index --assume-unchanged'
|
|
alias giI='git update-index --no-assume-unchanged'
|
|
alias gir='git reset'
|
|
alias giR='git reset --patch'
|
|
alias gix='git rm -r --cached'
|
|
alias giX='git rm -rf --cached'
|
|
|
|
# Log (l)
|
|
alias gl='git log --topo-order --pretty=medium'
|
|
alias glf='git log --topo-order --stat --pretty=fuller'
|
|
alias gls='git log --topo-order --stat --pretty=medium'
|
|
alias gld='git log --topo-order --stat --patch --full-diff --pretty=medium'
|
|
alias glo='git log --topo-order --pretty=oneline'
|
|
alias glg='git log --topo-order --all --graph --pretty=oneline'
|
|
alias glc='git shortlog --summary --numbered'
|
|
alias glS='git log --show-signature'
|
|
|
|
# Merge (m)
|
|
alias gm='git merge'
|
|
alias gmC='git merge --no-commit'
|
|
alias gmF='git merge --no-ff'
|
|
alias gma='git merge --abort'
|
|
alias gmt='git mergetool'
|
|
|
|
# Push (p)
|
|
alias gp='git push'
|
|
alias gpf='git push --force-with-lease'
|
|
alias gpF='git push --force'
|
|
alias gpa='git push --all'
|
|
alias gpA='git push --all && git push --tags'
|
|
alias gpt='git push --tags'
|
|
alias gpc='git push --set-upstream origin (git-branch-current 2> /dev/null)'
|
|
alias gpp='git pull origin (git-branch-current 2> /dev/null) && git push origin (git-branch-current 2> /dev/null)'
|
|
|
|
# Rebase (r)
|
|
alias gr='git rebase'
|
|
alias gra='git rebase --abort'
|
|
alias grc='git rebase --continue'
|
|
alias gri='git rebase --interactive'
|
|
alias grs='git rebase --skip'
|
|
|
|
# Remote (R)
|
|
alias gR='git remote'
|
|
alias gRl='git remote --verbose'
|
|
alias gRa='git remote add'
|
|
alias gRx='git remote rm'
|
|
alias gRm='git remote rename'
|
|
alias gRu='git remote update'
|
|
alias gRp='git remote prune'
|
|
alias gRs='git remote show'
|
|
alias gRb='git-hub-browse'
|
|
|
|
# Stash (s)
|
|
alias gs='git stash'
|
|
alias gsa='git stash apply'
|
|
alias gsx='git stash drop'
|
|
alias gsX='git-stash-clear-interactive'
|
|
alias gsl='git stash list'
|
|
alias gsL='git-stash-dropped'
|
|
alias gsd='git stash show --patch --stat'
|
|
alias gsp='git stash pop'
|
|
alias gsr='git-stash-recover'
|
|
alias gss='git stash save --include-untracked'
|
|
alias gsS='git stash save --patch --no-keep-index'
|
|
alias gsw='git stash save --include-untracked --keep-index'
|
|
|
|
# Submodule (S)
|
|
alias gS='git submodule'
|
|
alias gSa='git submodule add'
|
|
alias gSf='git submodule foreach'
|
|
alias gSi='git submodule init'
|
|
alias gSI='git submodule update --init --recursive'
|
|
alias gSl='git submodule status'
|
|
alias gSm='git-submodule-move'
|
|
alias gSs='git submodule sync'
|
|
alias gSu='git submodule foreach git pull origin master'
|
|
alias gSx='git-submodule-remove'
|
|
|
|
# Tag (t)
|
|
alias gt='git tag'
|
|
alias gtl='git tag -l'
|
|
alias gts='git tag -s'
|
|
alias gtv='git verify-tag'
|
|
|
|
# Working Copy (w)
|
|
alias gwS='git status --ignore-submodules=none --short'
|
|
alias gws='git status --ignore-submodules=none'
|
|
alias gwd='git diff --no-ext-diff'
|
|
alias gwD='git diff --no-ext-diff --word-diff'
|
|
alias gwr='git reset --soft'
|
|
alias gwR='git reset --hard'
|
|
alias gwc='git clean -n'
|
|
alias gwC='git clean -f'
|
|
alias gwx='git rm -r'
|
|
alias gwX='git rm -rf'
|
|
|
|
# Open modified files
|
|
# ACMRU = Added || Copied || Modified || Renamed || Unmerged
|
|
# Edit all uncommitted files that have changes since the last commit (be they staged or unstaged)
|
|
alias vd="nvim (git diff HEAD --name-only --diff-filter=ACMR)"
|
|
# Edit all staged files that have changes since the last commit
|
|
alias vds="nvim (git diff --staged --name-only --diff-filter=ACMR)"
|
|
# Edit all files that were altered in the last commit
|
|
alias vdc="nvim (git diff HEAD^ --name-only --diff-filter=ACMR)"
|
|
# Edit files changed since master
|
|
alias vdm="nvim (git diff master --name-only --diff-filter=ACMR)"
|
|
# Edit files unmerged
|
|
alias vdu="nvim (git diff --name-only --diff-filter=U | uniq)"
|
|
# Add unmerged files
|
|
alias vdua="git add (git diff --name-only --diff-filter=U)"
|
|
|
|
# Git fzf helper functions
|
|
# https://github.com/junegunn/fzf/wiki/Examples-(fish)
|
|
function fco -d "Fuzzy-find and checkout a branch"
|
|
git branch --all | grep -v HEAD | string trim | fzf | read -l result; and git checkout "$result"
|
|
end
|
|
|
|
function fcoc -d "Fuzzy-find and checkout a commit"
|
|
git log --pretty=oneline --abbrev-commit --reverse | fzf --tac +s -e | awk '{print $1;}' | read -l result; and git checkout "$result"
|
|
end
|
|
|
|
# https://gist.github.com/gabesoft/b6e5e959c4cb11ed257d41edb07d47cb
|
|
# Modify to use --exact flag for fzf and delta as pager
|
|
function fbr --description "Git browse commits"
|
|
set -l log_line_to_hash "echo {} | grep -o '[a-f0-9]\{7\}' | head -1"
|
|
set -l view_commit "$log_line_to_hash | xargs -I % sh -c 'git show --color=always % | delta | less -R'"
|
|
set -l copy_commit_hash "$log_line_to_hash | xclip"
|
|
set -l git_checkout "$log_line_to_hash | xargs -I % sh -c 'git checkout %'"
|
|
set -l open_cmd "open"
|
|
|
|
if test (uname) = Linux
|
|
set open_cmd "xdg-open"
|
|
end
|
|
|
|
set github_open "$log_line_to_hash | xargs -I % sh -c '$open_cmd https://github.\$(git config remote.origin.url | cut -f2 -d. | tr \':\' /)/commit/%'"
|
|
|
|
git log --color=always --format='%C(auto)%h%d %s %C(green)%C(bold)%cr% C(blue)%an' | \
|
|
fzf --exact --no-sort --reverse --tiebreak=index --no-multi --ansi \
|
|
--preview="$view_commit" \
|
|
--header="ENTER to view, CTRL-Y to copy hash, CTRL-O to open on GitHub, CTRL-X to checkout, CTRL-C to exit" \
|
|
--bind "enter:execute:$view_commit" \
|
|
--bind "ctrl-y:execute:$copy_commit_hash" \
|
|
--bind "ctrl-x:execute:$git_checkout" \
|
|
--bind "ctrl-o:execute:$github_open"
|
|
end
|
|
|
|
fzf_key_bindings
|