From bb3cfbc180e98fa2b8cb92795492d74c96b5d465 Mon Sep 17 00:00:00 2001 From: Alen Date: Tue, 26 Sep 2023 00:04:07 +0400 Subject: Add giti function --- dot_config/zsh/dot_zshrc | 2 +- dot_config/zsh/functions/giti | 27 +++++++++++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 dot_config/zsh/functions/giti 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" -- cgit 1.4.1-2-gfad0