Skip to content

Commit

Permalink
My dotfiles
Browse files Browse the repository at this point in the history
  • Loading branch information
hilli committed Apr 2, 2022
1 parent d48cbcc commit 87ebb83
Show file tree
Hide file tree
Showing 45 changed files with 2,829 additions and 2 deletions.
64 changes: 64 additions & 0 deletions .chezmoi.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
---
edit:
command: "code"
args: ["--wait"]
color: true

{{/* onepassword:
command: "op"
prompt: false */}}
{{- $name := "Jens Hilligsøe" -}}
{{- $email := "[email protected]" -}}
{{- $github_user := "hilli" -}}
{{- $codespaces := env "CODESPACES" | not | not -}}
{{- $ephemeral := false -}}
{{- $personal := false -}}
{{- writeToStdout "Writing chezmoi config\n" -}}
{{/* work around unreliable hostname on darwin */}}
{{- $hostname := .chezmoi.hostname -}}
{{- if eq .chezmoi.os "darwin" -}}
{{- $hostname = output "scutil" "--get" "ComputerName" | trim -}}
{{- end -}}
{{/* Determine ownership from hostname */}}
{{- if eq $hostname "miniM1" "ultra1" "maclap1" -}}
{{- writeToStdout "Personal macOS host detected from hostname...\n" -}}
{{- $personal = true -}}
{{- end }}

{{- if eq .chezmoi.os "linux" }}
{{ $computerName := output "hostname" | trim }}
{{- if $codespaces -}}
{{- writeToStdout "Codespaces detected...\n" -}}
sourceDir: {{ .chezmoi.sourceDir | quote }}
{{- $email = "[email protected]" -}}
{{- $personal = false -}}
{{- $ephemeral = true -}}
{{- else if eq $hostname "nuc1" -}}
{{- writeToStdout "Personal Linux host detected from hostname...\n" -}}
{{- $personal = true -}}
{{- $ephemeral = false -}}
{{- end -}}
{{- end }}

{{/* {{- writeToStdout "Personal: " ($personal | quote) "\n" -}} */}}
{{/* {{- writeToStdout "Ephemeral: " ($ephemeral | quote) "\n" -}} */}}

{{- if not $ephemeral }}
encryption: "age"
age:
identity: "~/.age-key.txt"
recipient: "age1dzj2wu2xg927nkqwtrx2fm7hc8jv9qkyl58y9zxkcvj5pgppdp5s54343g"
{{ end -}}

data:
name: {{ $name }}
ephemeral: {{ $ephemeral }}
personal: {{ $personal }}
email: {{ $email }}
codespaces: {{ $codespaces }}
hostname: {{ $hostname }}
github_user: {{ $github_user }}

useBuiltinAge: true

{{ writeToStdout "chezmoi config done.\n" }}
34 changes: 34 additions & 0 deletions .chezmoiexternal.yaml.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
---
.oh-my-zsh:
type: archive
url: https://github.com/ohmyzsh/ohmyzsh/archive/master.tar.gz
extract: true
refreshPeriod: 168h
.oh-my-zsh/custom/plugins/zsh-syntax-highlighting
type: archive
url: "https://github.com/zsh-users/zsh-syntax-highlighting/archive/master.tar.gz"
exact: true
stripComponents: 1
refreshPeriod: "168h"
.oh-my-zsh/custom/plugins/zsh-autosuggestions
type: archive
url: "https://github.com/zsh-users/zsh-autosuggestions/archive/refs/tags/v0.7.0.tar.gz"
exact: true
stripComponents: 1
{{- if and (eq .chezmoi.os "linux") .personal (not .ephemeral) }}
{{- $ageVersion := "1.0.0" }}
.local/bin/age:
type: "file"
url: "https://github.com/FiloSottile/age/releases/download/v{{ $ageVersion }}/age-v{{ $ageVersion }}-{{ .chezmoi.os }}-{{ .chezmoi.arch }}.tar.gz"
executable: true
.local/bin/age.filter:
command: "tar"
args: ["--extract", "--file", "/dev/stdin", "--gzip", "--to-stdout", "age/age"]
.local/bin/age-keygen:
type: "file"
url: "https://github.com/FiloSottile/age/releases/download/v{{ $ageVersion }}/age-v{{ $ageVersion }}-{{ .chezmoi.os }}-{{ .chezmoi.arch }}.tar.gz"
executable: true
.local/bin/age-keygen.filter:
command: tar
args: ["--extract", "--file", "/dev/stdin", "--gzip", "--to-stdout", "age/age-keygen"]
{{- end }}
13 changes: 13 additions & 0 deletions .chezmoiignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
install.sh
setup.sh
LICENSE
README.md
Brewfile
Brewfile.lock.json
Brewfile.home
Brewfile.home.lock.json
Brewfile.work
Brewfile.work.lock.json
.vscode
.devcontainer
age-key.txt.age
73 changes: 73 additions & 0 deletions .chezmoiscripts/darwin/run_onchange_after_configure.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{{ if (eq .chezmoi.os "darwin") -}}
#!/bin/bash

set -eufo pipefail

# https://github.com/mathiasbynens/dotfiles/blob/main/.macos

defaults write NSGlobalDomain AppleInterfaceStyle Dark
defaults write NSGlobalDomain AppleLanguages -array en-US da-DK
defaults write NSGlobalDomain AppleLocale en_DK
defaults write NSGlobalDomain InitialKeyRepeat -int 68
defaults write NSGlobalDomain KeyRepeat -int 6
defaults write NSGlobalDomain NSAutomaticCapitalizationEnabled -bool true
defaults write NSGlobalDomain NSAutomaticPeriodSubstitutionEnabled -bool true
defaults write NSGlobalDomain NSAutomaticQuoteSubstitutionEnabled -bool true
defaults write NSGlobalDomain NSAutomaticSpellingCorrectionEnabled -bool true
defaults write NSGlobalDomain NSAutomaticTextCompletionEnabled -bool true
defaults write NSGlobalDomain NSLinguisticDataAssetsRequested -array en da
defaults write NSGlobalDomain WebAutomaticSpellingCorrectionEnabled -bool true


defaults write com.apple.dock autohide -bool false
defaults write com.apple.dock autohide-delay -float 0
defaults write com.apple.dock autohide-time-modifier -float 0
defaults write com.apple.dock launchanim -bool false
defaults write com.apple.dock orientation right
defaults write com.apple.dock show-recents -bool true

defaults write com.apple.finder _FXShowPosixPathInTitle -bool true

defaults write com.apple.systempreferences NSQuitAlwaysKeepsWindows -bool false

if [ "$(command -v dockutil)" ]; then
for dockItemLabel in \
Mail \
TV \
News \
Numbers \
Keynote \
Pages ; do
dockutil --find "$dockItemLabel" >/dev/null && dockutil --no-restart --remove "$dockItemLabel" || true
done

# Add apps in the order I want
PREVIOUS_APP=""
for app in \
Safari \
'Microsoft Edge' \
Music \
Messages \
Slack \
Zoom.us \
1Password \
'Visual Studio Code' \
iTerm \
kitty \
Obsidian \
Notes \
Reminders ; do
if [ -n "${PREVIOUS_APP}" ]; then
dockutil --no-restart --add "/Applications/${app}.app" --after "${PREVIOUS_APP}" --replacing "$app"
else
dockutil --no-restart --add "/Applications/${app}.app" --replacing "$app"
fi
PREVIOUS_APP="${app}"
done

# Spark is a bit odd placed
dockutil --add /Applications/Spark.localized/Spark.app --after "Slack" --replacing "Spark"
fi

{{/* Using Spark to do a dockutil without the --no-restart instead of a otherwise needed `killall Dock` */}}
{{- end -}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
{{- if (eq .chezmoi.os "darwin") -}}
#!/bin/bash
set -eufo pipefail

script_dir="{{ .chezmoi.sourceDir }}"

function banner {
if [ "${TERM}" = "dumb" ]; then
echo ""
echo "######## $1 ########"
echo ""
else
echo ""
echo "$(tput setaf 5)######## $1 ########$(tput sgr0)"
echo ""
fi
}

banner "macOS package install"

# Install Homebrew
if [ ! "$(command -v brew)" ]; then
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
fi
# Install packages needed
if [ ! "$(command -v mas)" ]; then
brew install mas -
fi
cd "${script_dir}" || exit

# Brewfile hashes (To rerun this script when Brewfile changes):
# Brewfile: {{ include "Brewfile" | sha256sum }}
# Brewfile.home: {{ include "Brewfile.home" | sha256sum }}
# Brewfile.work: {{ include "Brewfile.work" | sha256sum }}

brew bundle --no-lock --file Brewfile
{{- if eq .personal true }}
brew bundle --no-lock --file Brewfile.home
{{- end }}
{{- if eq .personal false }}
brew bundle --no-lock --file Brewfile.work
{{- end }}

{{- end -}}
58 changes: 58 additions & 0 deletions .chezmoiscripts/linux/run_onchange_before_install-packages.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{{- if eq .chezmoi.os "linux" -}}
#!/bin/bash
set -eufo pipefail
script_dir="{{ .chezmoi.sourceDir }}"

function banner {
if [ "${TERM}" = "dumb" ]; then
echo ""
echo "######## $1 ########"
echo ""
else
echo ""
echo "$(tput setaf 5)######## $1 ########$(tput sgr0)"
echo ""
fi
}

function info {
if [ "${TERM}" = "dumb" ]; then
echo "INFO: $1"
else
echo "$(tput setaf 2)INFO: $1$(tput sgr0)"
fi
}

banner "Linux stuff"

banner "apt"
sudo apt update -y
PACKAGES=""
for i in $(cat {{ .chezmoi.sourceDir }}/Aptfile); do
PACKAGES="${PACKAGES} ${i}"
done
sudo apt-get -y install ${PACKAGES}

banner "starship"
curl -fsSL https://starship.rs/install.sh -o install_starship.sh
chmod +x install_starship.sh
sudo ./install_starship.sh --force -y
rm ./install_starship.sh

if [ "$(command -v gh)" ]; then
version=$(gh version)
info "gh ${version} is already installed"
else
info "installing gh..."
url="https://api.github.com/repos/cli/cli/releases/latest"
version=$(curl -sSL "${url}" | grep '"tag_name"' | sed -E 's/.*"([^"]+)".*/\1/' | cut -c2-)
info "will install gh version ${version}"
url="https://github.com/cli/cli/releases/download/v${version}/gh_${version}_linux_amd64.tar.gz"
curl -sSL ${url} -o gh_${version}_linux_amd64.tar.gz
tar xvf gh_${version}_linux_amd64.tar.gz
sudo cp gh_${version}_linux_amd64/bin/gh /usr/local/bin/
sudo rm -rf gh_${version}_linux_amd64*
info "installed gh ${version}"
fi

{{- end -}}
14 changes: 14 additions & 0 deletions .chezmoiscripts/run_codespace.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if .codespaces -}}
#!/bin/bash
if [[ ("${GITHUB_REPOSITORY}" = "github/github") ]]; then
cd /workspaces/github || exit 0

# Enable /test to be indexed in solargraph
ruby -p -i -e "gsub(/ - test/, '# - test')" .solargraph.yml
git update-index --skip-worktree .solargraph.yml
if [ "$(command -v code)" ]; then
code --install-extension castwide.solargraph --install-extension ethan-reesor.vscode-byebug 2>&1 > /dev/null
fi

fi
{{ end }}
14 changes: 14 additions & 0 deletions .chezmoiscripts/run_generate_completion.sh.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{{- if or (eq .chezmoi.os "darwin") (eq .chezmoi.os "linux") -}}
#!/bin/bash

mkdir -p "${HOME}/.local/share/site-functions"
{{ if eq .chezmoi.os "darwin" }}
# Set macOS defaults
echo Generating zsh completions for macOS
# op completion zsh >"${HOME}.local/share/site-functions/op.zsh"
{{ else if eq .chezmoi.os "linux" }}
# Set Linux defaults
echo Generating zsh completions for Linux
gh completion -s zsh >"${HOME}/.local/share/site-functions/gh.zsh"
{{ end }}
{{ end }}
15 changes: 15 additions & 0 deletions .chezmoiscripts/run_once_chsh.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

if [ "$(command -v zsh)" ]; then
# What shell is the user currently using?
if [ "$(uname)" = "Darwin" ]; then
myshell=$(basename "$(dscl . -read "${HOME}" UserShell | sed 's/UserShell: //')")
else
myshell=$(basename "$(grep """$(whoami)""" /etc/passwd | cut -f 7 -d :)")
fi
if [ "${myshell}" != "zsh" ]; then
# Set zsh as default shell.
echo Running sudo to change your shell to zsh.
sudo chsh -s "$(which zsh)" "$(whoami)"
fi
fi
5 changes: 5 additions & 0 deletions .chezmoiscripts/run_onchange_go_tools.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash
if [ "$(command -v go)" ]; then
echo Installing go tools
go install golang.org/x/review/git-codereview@latest
fi
1 change: 1 addition & 0 deletions .chezmoiversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.14.0
12 changes: 12 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.231.0/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] Ubuntu version (use hirsuite or bionic on local arm64/Apple Silicon): hirsute, focal, bionic
ARG VARIANT="hirsute"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# [Optional] Uncomment this section to install additional OS packages.
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
# && apt-get -y install --no-install-recommends <your-package-list-here>

# Install chezmoi to /usr/bin/chezmoi
RUN cd /usr && sudo sh -c "$(curl -fsLS chezmoi.io/get)"
Loading

0 comments on commit 87ebb83

Please sign in to comment.