Skip to content

Commit

Permalink
Merge pull request #10 from bcdady/fmt/tmpl
Browse files Browse the repository at this point in the history
format: improve templated lines and fixup gitconfig
  • Loading branch information
bcdady authored Dec 26, 2024
2 parents f03f02c + b1e1cb1 commit 638ae13
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 46 deletions.
File renamed without changes.
8 changes: 4 additions & 4 deletions dot_my_env.tmpl
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{ if eq .chezmoi.os "darwin" }}
{{- if eq .chezmoi.os "darwin" }}
#!/bin/zsh
{{ else if eq .chezmoi.os "linux" }}
{{- else if eq .chezmoi.os "linux" }}
# linux
#!/usr/bin/bash
{{ end }}
#!/bin/bash
{{- end }}
echo "Starting '${0}'"

# ensure go path is defined, and also add GOPATH/bin in PATH
Expand Down
18 changes: 9 additions & 9 deletions dot_my_tools.tmpl
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{ if eq .chezmoi.os "darwin" }}
{{- if eq .chezmoi.os "darwin" }}
#!/bin/zsh
{{ else if eq .chezmoi.os "linux" }}
{{- else if eq .chezmoi.os "linux" }}
# linux
#!/bin/bash
{{ end }}
{{- end }}
echo "Starting '${0}'"

{{ if eq .chezmoi.os "linux" }}
{{- if eq .chezmoi.os "linux" }}
if [[ "$TERM_PROGRAM" != "WarpTerminal" ]]; then
echo 'Configuring shell history'
# Set up Shell History
Expand All @@ -26,7 +26,7 @@ if [[ "$TERM_PROGRAM" != "WarpTerminal" ]]; then
# if this is interactive shell, then bind 'kill last command' to Ctrl-x k
if [[ $- =~ .*i.* ]]; then bind '"\C-xk": "\C-a hstr -k \C-j"'; fi
fi
{{ end }}
{{- end }}

# asdf
# shellcheck disable=SC1091
Expand All @@ -41,9 +41,9 @@ test "$TERM_PROGRAM" = "WarpTerminal" || source /usr/share/bash-completion/compl
# aws cli autocomplete, with aws installed via asdf
test "$TERM_PROGRAM" = "WarpTerminal" || complete -C "$(asdf which aws | sed 's/bin\/aws/bin\/aws_completer/')" aws

{{ if eq .chezmoi.os "linux" }}
{{- if eq .chezmoi.os "linux" }}
test "$TERM_PROGRAM" = "WarpTerminal" || test -f ~/.resh/shellrc || curl -fsSL https://raw.githubusercontent.com/curusarn/resh/master/scripts/rawinstall.sh | bash
{{ end }}
{{- end }}

# list available versions of python
echo 'Available python (3) versions / updates:'
Expand All @@ -57,7 +57,7 @@ echo 'Upgrade PIP'
command -v python3 && python3 -m pip install --user --upgrade pip

echo ''
{{ if eq .chezmoi.os "linux" }}
{{- if eq .chezmoi.os "linux" }}
# configure vpn aliases for CLI on linux

# OpenVPN CLI
Expand All @@ -83,7 +83,7 @@ if [[ "$TERM_PROGRAM" != "WarpTerminal" ]]; then
command -v starship || curl -sS https://starship.rs/install.sh | sh
eval "$(starship init bash)"
fi
{{ end }}
{{- end }}

# Use AWS CLI to setup kubeconfig if necessary
if [[ $(grep -c sap-prod ~/.kube/config) -eq 0 ]]; then
Expand Down
20 changes: 6 additions & 14 deletions dot_profile.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,16 @@
# for ssh logins, install and configure the libpam-umask package.
#umask 022

{{ if eq .chezmoi.os "darwin" }}

{{- if eq .chezmoi.os "darwin" }}
# if running zsh
if [ -n "$ZSH_VERSION" ]; then
# include .bashrc if it exists
# include .zhrc if it exists
if [ -f "$HOME/.zshrc" ]; then
echo "Sourcing ${HOME}/.zshrc"
. "$HOME/.zshrc"
fi
fi

{{ else if eq .chezmoi.os "linux" }}

{{- else if eq .chezmoi.os "linux" }}
# if running bash
if [ -n "$BASH_VERSION" ]; then
# include .bashrc if it exists
Expand All @@ -30,9 +27,7 @@ if [ -n "$BASH_VERSION" ]; then
. "$HOME/.bashrc"
fi
fi

{{ end }}

{{- end }}

# set PATH so it includes user's bin if it exists
if [ -d "$HOME/bin" ]; then
Expand All @@ -44,12 +39,9 @@ if [ -d "$HOME/.local/bin" ]; then
PATH="$HOME/.local/bin:$PATH"
fi

{{ if eq .chezmoi.os "darwin" }}

{{- if eq .chezmoi.os "darwin" }}
test -e "${HOME}/.iterm2_shell_integration.bash" && source "${HOME}/.iterm2_shell_integration.bash"

{{ end }}

{{- end }}
# load cargo env, if it exists
if [ -f "$HOME/.cargo/env" ]; then
. "$HOME/.cargo/env"
Expand Down
File renamed without changes.
26 changes: 13 additions & 13 deletions private_dot_gitconfig.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -65,28 +65,28 @@
aliases = config --get-regexp '^alias\\.'

[user]
[credential]
helper = cache
name = Bryan Dady
[credential]
# https://learn.microsoft.com/en-us/azure/devops/repos/git/git-config?view=azure-devops&tabs=git-command-line#credential-helper
# helper = store
helper = store
[init]
defaultBranch = main
[pull]
# https://github.com/git/git/commit/66713ef3b00933755cdeff1ae823dda7b5843640
rebase = preserve
rebase = merges
[core]
# https://docs.github.com/en/get-started/getting-started-with-git/configuring-git-to-handle-line-endings
# On Linux, use "input"
autocrlf = input
[diff]
# Also: EDITOR is probably set in env
{{ if eq .chezmoi.os "darwin" }}
{{- if eq .chezmoi.os "darwin" }}
guitool = code -r
tool = code -rmeld
{{ else if eq .chezmoi.os "linux" }}
{{- else if eq .chezmoi.os "linux" }}
guitool = meld
tool = meld
{{ end }}
{{- end }}
guitool = meld
tool = meld
[rebase]
Expand All @@ -97,17 +97,17 @@
[http]
# for macOS, this should maybe be updated to openssl
# for Windows, this should be updated to schannel
{{ if eq .chezmoi.os "darwin" }}
{{- if eq .chezmoi.os "darwin" }}
sslBackend = openssl
{{ else if eq .chezmoi.os "linux" }}
{{- else if eq .chezmoi.os "linux" }}
sslBackend = gnutls
{{ end }}
{{- end }}
[merge]
{{ if eq .chezmoi.os "darwin" }}
{{- if eq .chezmoi.os "darwin" }}
tool = code
{{ else if eq .chezmoi.os "linux" }}
{{- else if eq .chezmoi.os "linux" }}
tool= meld
{{ end }}
{{- end }}
[filter "lfs"]
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
Expand Down
6 changes: 3 additions & 3 deletions run_asdf_setup.tmpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{{ if eq .chezmoi.os "darwin" }}
{{- if eq .chezmoi.os "darwin" }}
#!/bin/zsh

# Install ASDF for Oh-My-ZSH
https://github.com/ohmyzsh/ohmyzsh/tree/master/plugins/asdf
git clone https://github.com/asdf-vm/asdf.git ~/.asdf
{{ else if eq .chezmoi.os "linux" }}
{{- else if eq .chezmoi.os "linux" }}
#!/bin/bash

# Install ASDF from github
LATEST_VERSION=$(curl -sL https://api.github.com/repos/asdf-vm/asdf/releases/latest | jq -r ".tag_name" | cut -c2-)
git clone https://github.com/asdf-vm/asdf.git ~/.asdf --branch "v${LATEST_VERSION}"

{{ end }}
{{- end }}
6 changes: 3 additions & 3 deletions run_brew_setup.tmpl
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/bash
{{ if eq .chezmoi.os "darwin" }}
{{- if eq .chezmoi.os "darwin" }}
# Install Homebrew
# https://brew.sh/
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
{{ else if eq .chezmoi.os "linux" }}
{{- else if eq .chezmoi.os "linux" }}
echo "Detected Linux; Installing snapd"
# This may need to be reconsidered, if it turns out to be unsafe
# to install snapd on a system that already has it
echo "Updating APT"
sudo apt update
echo "Installing snapd"
sudo apt install snapd
{{ end }}
{{- end }}

0 comments on commit 638ae13

Please sign in to comment.