summary refs log tree commit diff
path: root/dot_config/zsh
diff options
context:
space:
mode:
Diffstat (limited to 'dot_config/zsh')
-rw-r--r--dot_config/zsh/dot_zshrc2
-rw-r--r--dot_config/zsh/functions/giti27
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"