Procházet zdrojové kódy

Creating profile-git for git utilities.
Only run .profile-p4/.profile-git if the executable exists

Samuel Jaffe před 8 roky
rodič
revize
96913e8e56
2 změnil soubory, kde provedl 33 přidání a 2 odebrání
  1. 27 0
      profile-git
  2. 6 2
      profile-util

+ 27 - 0
profile-git

@@ -0,0 +1,27 @@
+git-ignore() {
+  local site="https://raw.githubusercontent.com/github/gitignore/master"
+  if [[ $1 == "--global" ]]; then
+    shift
+    ignore_file=${HOME}/.gitignore_global
+    site+="/Global"
+  else
+    ignore_file="./.gitignore"
+  fi
+  wget -qO- "${site}/${1}.gitignore" >> "${ignore_file}"
+}
+
+git-create() {
+  mkcd "${1}"; shift
+  git init
+  touch .gitignore
+  local message="Initializing repository"
+  if [[ $# -ge 1 ]]; then
+    for i in "$@"; do git-ignore "${i}"; done
+    message+=" with ignore lists: [ $1 $(printf ", %s" "${@:2}")]"
+  fi
+  git add .gitignore
+  git commit -m "${message}"
+}
+
+alias git-graph="git log --graph --pretty=oneline --abbrev-commit --decorate --all"
+

+ 6 - 2
profile-util

@@ -28,7 +28,6 @@ unlink-tools() {
 }
 
 alias listall="list -A"
-alias git-graph="git log --graph --pretty=oneline --abbrev-commit --decorate --all"
 alias disk-usage="ls -A | xargs du -shc | sort -h"
 
 alias reload="source ~/.bashrc"
@@ -106,6 +105,10 @@ swap() {
   mv "${tmpfile}" "${2}"
 }
 
+has() {
+  which "${1}" &>/dev/null
+}
+
 alias coms="${HOME}/tools/comstore/commands.sh"
 
 clrun() {
@@ -120,5 +123,6 @@ else
   . ${HOME}/.profile-linux
 fi
 
-source ${HOME}/.profile-p4
+has git && . ${HOME}/.profile-git
+has p4 && . ${HOME}/.profile-p4