Skip to content
Permalink
Browse files

Merge branch 'master' of https://github.com/neeasade/dotfiles

  • Loading branch information...
neeasade committed Jun 29, 2019
2 parents cb4199d + 64c483a commit eecbd97ee38e3e289f0ca311a586ad21281c92ad
Showing with 72 additions and 12 deletions.
  1. +2 −3 shell/.sh.d/environment_emacs
  2. +16 −7 shell/.sh.d/functions
  3. +53 −1 shell/.sh.d/git
  4. +1 −1 shell/.sh.d/style
@@ -10,7 +10,6 @@ if [ -z "$cur_shell" ]; then
cur_shell="${cur_shell##*/}"
fi


path_remove() {
PATH=${PATH//":$1:"/":"} # middle
PATH=${PATH/#"$1:"/} # beginning
@@ -32,7 +31,7 @@ emacs_timeout=$(iif 'has timeout' 'timeout 1' '')

# todo: tramp emacsclient?
[ "$cur_shell" = "zsh" ] && setopt SH_WORD_SPLIT
if has emacs && ! $REMOTE && silent $emacs_timeout emacsclient --eval "(progn t)"; then
if $ESHELL && ! $REMOTE && silent $emacs_timeout emacsclient --eval "(progn t)"; then
[ "$cur_shell" = "zsh" ] && unsetopt SH_WORD_SPLIT

eclient="emacsclient"
@@ -58,7 +57,7 @@ if has emacs && ! $REMOTE && silent $emacs_timeout emacsclient --eval "(progn t)
}

man() {
elisp "(woman \"$*\") (Man-cleanup-manpage)"
elisp "(woman \"$*\") (require 'man) (Man-cleanup-manpage)"
}

clear() {
@@ -212,16 +212,25 @@ passadd() {

gset() {
case $1 in
work)
git config user.name "$(pass name)"
git config user.email "$(pass email)"
pass)
git config user.name "$(pass git/name)"
git config user.email "$(pass git/email)"
;;
home)
git config user.name "neeasade"
git config user.email "neeasade@gmail.com"
manual)
echo name:; read _name
git config user.name "$_name"

echo email:; read _email
git config user.email "$_email"
;;
adhoc)
_name="$(getent passwd "$USER" | cut -d ':' -f 5 | sed 's/,//g')"
_name="${name:-$USER}"
git config user.name "$_name"
git config user.email "${USER}@$(hostname).machine"
;;
*)
echo unknown option
echo options: pass home adhoc
;;
esac
}
@@ -58,8 +58,51 @@ alias gfa='git fetch --all --prune'
alias gfo='git fetch origin'
alias gg='git gui citool'
alias gga='git gui citool --amend'
alias ggpur='ggu'

# flow:

# you have unstaged changes in files that were changed remote
# offer to stash, pull rebase (if rebase conflicts, exit), pop
# if no, pull rebase -- ask if there are conflicts in merge

gtest() {
git fetch --all

branch=$(git_current_branch)
merge_base="$(git merge-base HEAD origin/${branch})"

unstaged_diff="$(git diff --name-only)"
committed_and_unstaged_diff="$(git diff --name-only $merge_base)"
origin_committed_diff="$(git diff --name-only $merge_base origin/$(git_current_branch))"

overlapping() {
return test -z "$(echo "${1}\n${2}" | sort | uniq -d)"
}

# verbose
vgit() {
echo git "$@"
git "$@"
}

if overlapping "$origin_committed_diff" "$unstaged_diff"; then
echo -n "local changes - stash and rebase? [Y/n]"
read r
if [ -z "$r" ]; then
vgit stash
vgit rebase "origin/${branch}"
vgit stash pop
return
fi
fi

if overlapping "$committed_and_unstaged_diff" "$origin_committed_diff"; then
echo -n "remote conflict - rebase? [Y/n]"
fi
}

alias ggpull='git pull origin $(git_current_branch)'

alias ggpush='git push origin $(git_current_branch)'
alias ggsup='git branch --set-upstream-to=origin/$(git_current_branch)'
alias gpsup='git push --set-upstream origin $(git_current_branch)'
@@ -135,3 +178,12 @@ alias gup='git pull --rebase'
alias gupv='git pull --rebase -v'
alias glum='git pull upstream master'
alias gwch='git whatchanged -p --abbrev-commit --pretty=medium'

# todo: better name
# git tag replace with current head
gtr() {
git tag -d $1
git push origin :refs/tags/$1
git tag $1
git push origin $1
}
@@ -44,7 +44,7 @@ git_prompt() {
fi
else
if [ ! -z "${g_status}" ]; then
g_status=" $g_status"
g_status="|$g_status"
fi
echo "(${g_branch}${g_status}) "
fi

0 comments on commit eecbd97

Please sign in to comment.
You can’t perform that action at this time.