From 1ce47d897dfffb18d473574f97f57de0f8698edd Mon Sep 17 00:00:00 2001 From: Ivan Malison Date: Tue, 21 Jul 2015 16:51:23 -0700 Subject: [PATCH] add_github_remote. --- dotfiles/gitconfig | 1 + dotfiles/lib/shellenv/functions.sh | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/dotfiles/gitconfig b/dotfiles/gitconfig index ffd6742d..fa6e533e 100644 --- a/dotfiles/gitconfig +++ b/dotfiles/gitconfig @@ -21,6 +21,7 @@ ffo = !git ffr origin ffr = "!ffr() { git fetch $1 && git ff $1/$(git which-branch) && git suir; }; ffr" file-exists = "!f() { git ls-files $1 --error-unmatch > /dev/null 2> /dev/null; }; f" + add-gh-remote = "! add_github_remote" icd = "!d() { git difftool --no-prompt --extcmd 'icdiff' $@ | $(git config --get core.pager); }; d" icdl = "!d() { git difftool --no-prompt --extcmd 'icdiff --line-numbers' $@ | $(git config --get core.pager); }; d" ignore = "!i() { printf \"\n$1\" >> "`git root`/.gitignore"; }; i" diff --git a/dotfiles/lib/shellenv/functions.sh b/dotfiles/lib/shellenv/functions.sh index 588cd312..539ee7f3 100644 --- a/dotfiles/lib/shellenv/functions.sh +++ b/dotfiles/lib/shellenv/functions.sh @@ -390,3 +390,13 @@ function pkill_zsh { function find_by_size { find . -type f -size +$1 } + +function get_git_project_name { + # "$(basename $(git rev-parse --show-toplevel))" + basename $(git remotes | get_cols 2) +} + +function add_github_remote { + local project_name="$(get_git_project_name)" + git remote add "$1" "git@github.com:$1/$project_name" +}