diff options
author | Alen <alen@dotfiles.xyz> | 2023-09-26 00:04:07 +0400 |
---|---|---|
committer | Alen <alen@dotfiles.xyz> | 2023-09-26 00:04:07 +0400 |
commit | bb3cfbc180e98fa2b8cb92795492d74c96b5d465 (patch) | |
tree | f15893d0d381fde0d983630191bd8065495fac08 | |
parent | 7ecfc06316c905ab90763a5473d4aa04e85b59e1 (diff) |
Add giti function
-rw-r--r-- | dot_config/zsh/dot_zshrc | 2 | ||||
-rw-r--r-- | dot_config/zsh/functions/giti | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/dot_config/zsh/dot_zshrc b/dot_config/zsh/dot_zshrc index fcd6fc7..e1d01f1 100644 --- a/dot_config/zsh/dot_zshrc +++ b/dot_config/zsh/dot_zshrc @@ -9,5 +9,5 @@ export SAVEHIST=1000000 PROMPT="%F{15}%K{4}%n@%M:%~%f%k " RPROMPT="%(?.%F{10}%?.%F{9}%?)%f %T" -autoload -U compaudit compinit zrecompile +autoload -U compaudit compinit zrecompile giti autoload -U colors && colors diff --git a/dot_config/zsh/functions/giti b/dot_config/zsh/functions/giti new file mode 100644 index 0000000..ee0f4ec --- /dev/null +++ b/dot_config/zsh/functions/giti @@ -0,0 +1,27 @@ +#!/usr/bin/env zsh + +emulate -L zsh + +if [[ ${1} == '--help' || ${1} == '-h' || ${1} == '' ]]; then + echo "Usage: ${0} [--help|-h] [reference]" + return 0 +fi + +if [[ -f .gitignore ]]; then + echo '.gitignore already exists' + return 1 +fi + +local TEMP="$(mktemp)" +if curl --fail --silent "https://raw.githubusercontent.com/github/gitignore/main/${1}.gitignore" > "${TEMP}"; then + mv "${TEMP}" ".gitignore" +elif curl --fail --silent "https://raw.githubusercontent.com/github/gitignore/main/${(C)1}.gitignore" > "${TEMP}"; then + mv "${TEMP}" ".gitignore" +else + echo "Could not get ${1}" + return 2 +fi + +# Uncomment things I generally prefer uncommented +sed -i -E 's% *# *(.idea/|poetry.lock|Pipfile.lock|.python-version|pdm.lock)%\1%g' ".gitignore" +echo ".gitignore created" |