From 71946b3246f0a0b609dea85444202e92030bad43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fernando=20Alem=C3=A1n?= Date: Fri, 13 Oct 2023 12:01:27 -0500 Subject: [PATCH] Create base files and directories --- .shellcheckrc | 2 ++ mac | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 .shellcheckrc diff --git a/.shellcheckrc b/.shellcheckrc new file mode 100644 index 0000000..1e71d35 --- /dev/null +++ b/.shellcheckrc @@ -0,0 +1,2 @@ +disable=SC2016,SC2059,SC2154 +disable=SC3043 diff --git a/mac b/mac index c6be2cb..cccbede 100755 --- a/mac +++ b/mac @@ -1,2 +1,41 @@ #!/bin/sh + +fancy_echo() { + local fmt="$1"; shift + printf "\\n$fmt\\n" "$@" +} + +append_to_zshrc() { + local text="$1" zshrc + local skip_new_line="${2:-0}" + + if [ -w "$HOME/.zshrc.local" ]; then + zshrc="$HOME/.zshrc.local" + else + zshrc="$HOME/.zshrc" + fi + + if ! grep -Fqs "$text" "$zshrc"; then + if [ "$skip_new_line" -eq 1 ]; then + printf "%s\\n" "$text" >> "$zshrc" + else + printf "\\n%s\\n" "$text" >> "$zshrc" + fi + fi +} + +trap 'ret=$?; test $ret -ne 0 && printf "failed\n\n" >&2; exit $ret' EXIT + +set -e + +if [ ! -f "$HOME/.zshrc" ]; then + touch "$HOME/.zshrc" +fi + +if [ ! -d "$HOME/.bin/" ]; then + mkdir "$HOME/.bin" +fi + +append_to_zshrc 'export PATH="$HOME/.bin:$PATH"' + # ft=shell