mirror of
https://github.com/Lissy93/dotfiles.git
synced 2025-02-10 20:49:11 +01:00
:octocat: Adds function for generating .gitignore
This commit is contained in:
parent
ac906a5f7e
commit
750ac49a46
@ -27,6 +27,7 @@ alias gch="git checkout" # Switch the HEAD to <branch>
|
|||||||
alias gb="git branch" # Create a new <branch> from HEAD
|
alias gb="git branch" # Create a new <branch> from HEAD
|
||||||
alias gd="git diff" # Show all changes to untracked files
|
alias gd="git diff" # Show all changes to untracked files
|
||||||
alias gtree="git log --graph --oneline --decorate" # Show branch tree
|
alias gtree="git log --graph --oneline --decorate" # Show branch tree
|
||||||
|
alias gl='git log'
|
||||||
|
|
||||||
# Tags
|
# Tags
|
||||||
alias gt="git tag" # Tag the current commit, 1 param
|
alias gt="git tag" # Tag the current commit, 1 param
|
||||||
@ -49,6 +50,17 @@ alias gua="git reset --hard HEAD" # Resets all uncommited changes
|
|||||||
alias gnewmsg="git commit --amend -m" # Update <message> of previous commit
|
alias gnewmsg="git commit --amend -m" # Update <message> of previous commit
|
||||||
alias gclean="git clean -df" # Remove all untracked files
|
alias gclean="git clean -df" # Remove all untracked files
|
||||||
|
|
||||||
|
# Git LFS
|
||||||
|
alias glfsi='git lfs install'
|
||||||
|
alias glfst='git lfs track'
|
||||||
|
alias glfsls='git lfs ls-files'
|
||||||
|
alias glfsmi='git lfs migrate import --include='
|
||||||
|
|
||||||
|
# Push LFS changes to current branch
|
||||||
|
function gplfs() {
|
||||||
|
git lfs push origin "$(git_current_branch)" --all
|
||||||
|
}
|
||||||
|
|
||||||
# Shorthand clone (e.g. $ clone lissy93/dotfiles)
|
# Shorthand clone (e.g. $ clone lissy93/dotfiles)
|
||||||
function clone {
|
function clone {
|
||||||
default_service='github.com' # Used if full URL isn't specified
|
default_service='github.com' # Used if full URL isn't specified
|
||||||
@ -126,24 +138,26 @@ function gfetchrebase {
|
|||||||
|
|
||||||
alias gfrb="gfetchrebase"
|
alias gfrb="gfetchrebase"
|
||||||
|
|
||||||
# Fork a GitHub repo
|
# Integrates with gitignore.io to auto-populate .gitignore file
|
||||||
ghfork() {
|
function gignore() {
|
||||||
gitURL=${1:-"$(git config --get remote.origin.url)"}
|
curl -fLw '\n' https://www.gitignore.io/api/"${(j:,:)@}"
|
||||||
gitURL="${gitURL%.git}" # Remove .git from the end of the git URL
|
}
|
||||||
if [[ $gitURL =~ ^git@ ]]; then
|
_gitignoreio_get_command_list() {
|
||||||
gitURL="$(echo $gitURL | sed 's/git@//')" # Remove git@ from the start of the git URL
|
curl -sfL https://www.gitignore.io/api/list | tr "," "\n"
|
||||||
repo="$(echo $gitURL | sed 's/.*\///')" # Pull the repo name from the git URL
|
}
|
||||||
elif [[ $gitURL =~ ^https?:// ]]; then
|
_gitignoreio () {
|
||||||
repo="$(echo $gitURL | sed 's/.*\.com\///' | sed 's/.*\///')" # Pull the repo name from the git URL
|
compset -P '*,'
|
||||||
elif [[ ! -z $1 && ! -z $2 && "$1" != *\/* ]]; then
|
compadd -S '' `_gitignoreio_get_command_list`
|
||||||
repo="$2"
|
}
|
||||||
|
# Downloads specific git ignore template to .gitignore
|
||||||
|
gignore-apply () {
|
||||||
|
if [ -n $search_term ]; then
|
||||||
|
gignore $1 >> .gitignore
|
||||||
else
|
else
|
||||||
repo="$(echo $1 | sed 's/.*\///')"
|
echo "Expected a template to be specified. Run:"
|
||||||
|
echo " $ gignore list to view all options"
|
||||||
|
echo " $ gignore [template] to preview"
|
||||||
fi
|
fi
|
||||||
github "$@"
|
|
||||||
echo "🍴 Click 'Fork'"
|
|
||||||
user=$(whoami)
|
|
||||||
print -z clone "$user" "$repo"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# Helper function to return URL of current repo (based on origin)
|
# Helper function to return URL of current repo (based on origin)
|
||||||
|
Loading…
Reference in New Issue
Block a user