Skip to content

Commit

Permalink
git do git alias
Browse files Browse the repository at this point in the history
  • Loading branch information
kachick committed Jul 15, 2023
1 parent 38346a4 commit 9880a12
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .config/fish/conf.d/plugin-foreign-env.fish
2 changes: 1 addition & 1 deletion .config/fish/config.fish
9 changes: 8 additions & 1 deletion .config/git/config
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,11 @@
[alias]
fixup = commit --all --amend
empty = commit --allow-empty -m 'Add an empty commit'
current-branch = symbolic-ref --short HEAD
current = symbolic-ref --short HEAD
# default = !git symbolic-ref refs/remotes/origin/HEAD | cut -f4 -d'/' # made error in dirty?
switch-default = !git checkout main 2>/dev/null || git checkout master 2>/dev/null
upstream = !git remote | grep -E '^upstream$'|| git remote | grep -E '^origin$'
duster = remote update origin --prune
refresh = !git switch-default && git pull "$(git upstream)" "$(git current)"
# Depending gh poi :)
all = !git refresh && gh poi
21 changes: 0 additions & 21 deletions .config/nushell/config.nu
Original file line number Diff line number Diff line change
Expand Up @@ -694,27 +694,6 @@ let-env config = {
]
}

def git-main-branch [] {
git branch | lines | str replace '^ *(?:\*\s+(.+))?' '$1' | where ($it == "main" or $it == "master") | take 1
}

def git-upstream [] {
git remote | lines | str trim | where ($it == "upstream" or $it == "origin") | reverse | take 1
}

# https://www.nushell.sh/cookbook/git.html#delete-git-merged-branches
def git-delete-merged-branches [] {
git branch --merged | lines | where ($it != "* master" and $it != "* main") | each {|br| git branch -D ($br | str trim) } | str trim
}

def git-switch-default [] {
git switch (git-main-branch)
}

def git-cleanup-branches [] {
git-switch-default; git pull (git-upstream) (git current-branch); git fetch (git-upstream) --tags --prune; git-delete-merged-branches
}

def la [] {
ls --all | sort-by modified -r | sort-by type
}
Expand Down
6 changes: 0 additions & 6 deletions home/.aliases.sh
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
#!/usr/bin/env bash

alias git-switch-default='git checkout main 2>/dev/null || git checkout master 2>/dev/null'
alias git-upstream="git remote | grep -E '^upstream$'|| git remote | grep -E '^origin$'"
# https://github.com/kyanny/git-delete-merged-branches/pull/6
alias git-delete-merged-branches="git branch --merged | grep -vE '((^\*)|^ *(main|master)$)' | xargs -I % git branch -d %"
alias git-cleanup-branches='git-switch-default && git pull $(git-upstream) $(git current-branch) && git fetch $(git-upstream) --tags --prune && git-delete-merged-branches'

alias la='exa --long --all --group-directories-first'

alias zj='zellij attach "$(basename "$PWD")" || zellij --session "$(basename "$PWD")"'
Expand Down

0 comments on commit 9880a12

Please sign in to comment.