From af461e723411f4bea8c93ce1dd4e06db3e4e41cf Mon Sep 17 00:00:00 2001 From: Ismo Vuorinen Date: Tue, 6 Dec 2022 15:39:59 +0200 Subject: [PATCH] rcrc, conditional zshrc, allowed_signers --- .editorconfig | 19 ++++--- Brewfile | 11 ++++ README.md | 43 ++++++++++++++- alias => config/alias | 3 -- config/git/config | 1 + helper.sh | 38 +++++++++++++ install.sh | 6 ++- rcrc | 2 + ssh/allowed_signers | 0 ssh/config | 2 + zshrc | 123 +++++++++++++++++++++++------------------- 11 files changed, 180 insertions(+), 68 deletions(-) rename alias => config/alias (94%) create mode 100755 helper.sh create mode 100644 rcrc create mode 100644 ssh/allowed_signers create mode 100644 ssh/config diff --git a/.editorconfig b/.editorconfig index 1cdfed3..9f81d21 100644 --- a/.editorconfig +++ b/.editorconfig @@ -10,15 +10,18 @@ insert_final_newline = true # tab_width = 4 trim_trailing_whitespace = true -[*.sass] -# indent_size = 2 +[{*.yaml,*.yml}] +indent_size = 2 -[{*.bash,*.sh,*.zsh}] +[*.sh] +indent_style = space indent_size = 2 tab_width = 2 -[{*.ctp,*.hphp,*.inc,*.module,*.php,*.php4,*.php5,*.phtml}] -# max_line_length = 110 - -[{*.yaml,*.yml}] -indent_size = 2 +shell_variant = posix # like -ln=posix +binary_next_line = true # like -bn +switch_case_indent = true # like -ci +space_redirects = true # like -sr +keep_padding = false # like -kp +function_next_line = false # like -fn +never_split = true # like -ns diff --git a/Brewfile b/Brewfile index 90d7bd6..c0deaee 100644 --- a/Brewfile +++ b/Brewfile @@ -103,6 +103,8 @@ brew "lazydocker" brew "libvoikko" # Swiss Army Knife for macOS brew "m-cli" +# Mac App Store command-line interface +brew "mas" # Terminal-based visual file manager brew "midnight-commander" # Port scanning utility for large networks @@ -203,6 +205,8 @@ cask "quicklook-json" cask "quicklookase" # MySQL/MariaDB database management cask "sequel-ace" +# Collection of apps available by subscription +cask "setapp" # Application for inspecting installer packages cask "suspicious-package" # Quicklook extension for source files @@ -213,3 +217,10 @@ cask "visual-studio-code" cask "vlc" # Rust-based terminal cask "warp" +mas "1Password for Safari", id: 1569813296 +mas "GarageBand", id: 682658836 +mas "iMovie", id: 408981434 +mas "Keynote", id: 409183694 +mas "Numbers", id: 409203825 +mas "Pages", id: 409201541 +mas "Tailscale", id: 1475387142 diff --git a/README.md b/README.md index 4967679..f30f90a 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,25 @@ -# DotFiles +# .dotfiles + +The folder structure follows [XDG Base Directory Specification][xdg] where possible. ## Setup -## Other stuff +## rcrc + +Update install script + +```bash +rcup -B 0 -g > ~/.dotfiles/install.sh | shfmt -w -l ~/.dotfiles/install.sh +``` + +## brew + +Install everything described in `Brewfile` + +```bash +brew bundle install --force --file=~/.dotfiles/Brewfile +``` + Update `Brewfile` @@ -15,3 +32,25 @@ Enable automatic brew updates and upgrades. ```bash brew autoupdate start 43200 --upgrade --cleanup --immediate ``` + +## XDG Variables + +| Var | Default | +|--------------------|----------------------| +| Executables | `$HOME/.local/bin` | +| `$XDG_DATA_HOME` | `$HOME/.local/share` | +| `$XDG_STATE_HOME` | `$HOME/.local/state` | +| `$XDG_CONFIG_HOME` | `$HOME/.config` | + + +- `$XDG_DATA_HOME` defines the base directory relative to which user-specific data files should be stored. If `$XDG_DATA_HOME` is either not set or empty, a default equal to ` $HOME/.local/share` should be used. +- `$XDG_CONFIG_HOME` defines the base directory relative to which user-specific configuration files should be stored. If `$XDG_CONFIG_HOME` is either not set or empty, a default equal to `$HOME/.config` should be used. +- `$XDG_STATE_HOME` defines the base directory relative to which user-specific state files should be stored. If `$XDG_STATE_HOME` is either not set or empty, a default equal to `$HOME/.local/state` should be used. +- The `$XDG_STATE_HOME` contains state data that should persist between (application) restarts, but that is not important or portable enough to the user that it should be stored in `$XDG_DATA_HOME`. It may contain: + - actions history (logs, history, recently used files, …) + - current state of the application that can be reused on a restart (view, layout, open files, undo history, …) +- User-specific executable files may be stored in `$HOME/.local/bin`. Distributions should ensure this directory shows up in the UNIX `$PATH` environment variable, at an appropriate place. +- `$XDG_DATA_DIRS` defines the preference-ordered set of base directories to search for data files in addition to the `$XDG_DATA_HOME` base directory. The directories in `$XDG_DATA_DIRS` should be seperated with a colon ':'. + + +[xdg]: https://specifications.freedesktop.org/basedir-spec/basedir-spec-latest.html diff --git a/alias b/config/alias similarity index 94% rename from alias rename to config/alias index 8823c02..0c58cc5 100644 --- a/alias +++ b/config/alias @@ -19,9 +19,6 @@ if [[ $(uname) == 'Darwin' ]]; then alias p8a='$(brew --prefix php)/bin/php artisan' alias sail='[ -f sail ] && bash sail || bash vendor/bin/sail' - - # work related - alias geniemvpn='sudo openfortivpn -c ~/.local/openfortivpn.conf' fi alias watchx='watch -dpbc' diff --git a/config/git/config b/config/git/config index 063b0c1..b3bd631 100644 --- a/config/git/config +++ b/config/git/config @@ -55,5 +55,6 @@ format = ssh [gpg "ssh"] program = /Applications/1Password.app/Contents/MacOS/op-ssh-sign + allowedSignersFile = ~/.ssh/allowed_signers [commit] gpgsign = true diff --git a/helper.sh b/helper.sh new file mode 100755 index 0000000..4cd9bae --- /dev/null +++ b/helper.sh @@ -0,0 +1,38 @@ +#!/usr/bin/env bash +# +# Dotfiles and install helper +# + +# Helper variables, override with ENVs like `VERBOSE=1 helpers.sh help` +: ${VERBOSE:=0} +: ${CP:=/bin/cp} +: ${LN:=/bin/ln} +: ${MKDIR:=/bin/mkdir} +: ${RM:=/bin/rm} +: ${DIRNAME:=/usr/bin/dirname} + +case "$1" in + install) + echo "install stuff" + case "$2" in + *) + echo "-> $0 install [brew]" + esac + ;; + brew) + echo "brew commands" + ;; + dotfiles) + echo "dotfiles manager" + ;; + other) + echo "Other commands" + ;; + *) + echo $"Usage: $0 [install | brew | dotfiles | other]" + echo $" All commands have their own subcommands." + echo $" When in doubt run the subcommand to show list." + echo "" + exit 1 + ;; +esac diff --git a/install.sh b/install.sh index 1c8f8c5..630eb2e 100644 --- a/install.sh +++ b/install.sh @@ -63,15 +63,19 @@ handle_file_ln() { $MKDIR -p "$($DIRNAME "$2")" $LN -sf "$1" "$2" } -handle_file_ln "/Users/ivuorinen/.dotfiles/alias" "/Users/ivuorinen/.alias" handle_file_ln "/Users/ivuorinen/.dotfiles/bash_profile" "/Users/ivuorinen/.bash_profile" handle_file_ln "/Users/ivuorinen/.dotfiles/bashrc" "/Users/ivuorinen/.bashrc" +handle_file_ln "/Users/ivuorinen/.dotfiles/config/alias" "/Users/ivuorinen/.config/alias" handle_file_ln "/Users/ivuorinen/.dotfiles/config/antigen.zsh" "/Users/ivuorinen/.config/antigen.zsh" handle_file_ln "/Users/ivuorinen/.dotfiles/config/gh/config.yml" "/Users/ivuorinen/.config/gh/config.yml" handle_file_ln "/Users/ivuorinen/.dotfiles/config/git/config" "/Users/ivuorinen/.config/git/config" handle_file_ln "/Users/ivuorinen/.dotfiles/config/git/gitignore" "/Users/ivuorinen/.config/git/gitignore" +handle_file_ln "/Users/ivuorinen/.dotfiles/config/wtf/config.yml" "/Users/ivuorinen/.config/wtf/config.yml" handle_file_ln "/Users/ivuorinen/.dotfiles/git_profiles" "/Users/ivuorinen/.git_profiles" handle_file_ln "/Users/ivuorinen/.dotfiles/huskyrc" "/Users/ivuorinen/.huskyrc" handle_file_ln "/Users/ivuorinen/.dotfiles/local/bin/x-open-ports" "/Users/ivuorinen/.local/bin/x-open-ports" +handle_file_ln "/Users/ivuorinen/.dotfiles/rcrc" "/Users/ivuorinen/.rcrc" +handle_file_ln "/Users/ivuorinen/.dotfiles/ssh/allowed_signers" "/Users/ivuorinen/.ssh/allowed_signers" +handle_file_ln "/Users/ivuorinen/.dotfiles/ssh/config" "/Users/ivuorinen/.ssh/config" handle_file_ln "/Users/ivuorinen/.dotfiles/vuerc" "/Users/ivuorinen/.vuerc" handle_file_ln "/Users/ivuorinen/.dotfiles/zshrc" "/Users/ivuorinen/.zshrc" diff --git a/rcrc b/rcrc new file mode 100644 index 0000000..3d0332a --- /dev/null +++ b/rcrc @@ -0,0 +1,2 @@ +EXCLUDES="README.md install.sh Brewfile.lock.json Brewfile" +HOSTNAME=$(hostname -s) diff --git a/ssh/allowed_signers b/ssh/allowed_signers new file mode 100644 index 0000000..e69de29 diff --git a/ssh/config b/ssh/config new file mode 100644 index 0000000..10cab31 --- /dev/null +++ b/ssh/config @@ -0,0 +1,2 @@ +Host * + IdentityAgent "~/Library/Group Containers/2BUA8C4S2C.com.1password/t/agent.sock" diff --git a/zshrc b/zshrc index 4c39d60..8d37e99 100644 --- a/zshrc +++ b/zshrc @@ -2,80 +2,95 @@ [[ -f "$HOME/.fig/shell/zshrc.pre.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.pre.zsh" # shellcheck shell=bash -export PATH="/opt/homebrew/bin:/opt/homebrew/sbin:$PATH" - LOCAL_BIN="$HOME/.local/bin" -OPT_FOLDER="/usr/local/opt" -PHP_74=$(brew --prefix php@7.4)/bin -PHP_80=$(brew --prefix php@8.0)/bin -PHP_CUR=$(brew --prefix php)/bin + PYTHON_38="$HOME/Library/Python/3.8/bin" COMPOSER_DIR="$HOME/.composer/vendor/bin" -BREW_PYTHON=$(brew --prefix python@3.8)/bin -GNUBIN_DIR=$(brew --prefix coreutils)/libexec/gnubin -BREW_RUBY=$(brew --prefix ruby)/bin -BREW_GEMS=$(gem environment gemdir)/bin USR_SBIN=/usr/local/sbin -export PATH="$LOCAL_BIN:$PYTHON_38:$COMPOSER_DIR:$BREW_PYTHON:$GNUBIN_DIR:$BREW_GEMS:$BREW_RUBY:$USR_SBIN:$PATH" -source "$HOME/.config/antigen.zsh" +export PATH="/opt/homebrew/bin:$USR_SBIN:$PATH" -export NVM_DIR="$HOME/.nvm" -[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" # This loads nvm -[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" # This loads nvm bash_completion +if [ command -v brew &> /dev/null ]; then + BREW_BIN=$(brew --prefix)/bin + BREW_SBIN=$(brew --prefix)/sbin + + # PHP_74=$(brew --prefix php@7.4)/bin + # PHP_80=$(brew --prefix php@8.0)/bin + # PHP_CUR=$(brew --prefix php)/bin + BREW_PYTHON=$(brew --prefix python@3.8)/bin + GNUBIN_DIR=$(brew --prefix coreutils)/libexec/gnubin + BREW_RUBY=$(brew --prefix ruby)/bin + BREW_GEMS=$(gem environment gemdir)/bin + + export PATH="$BREW_PYTHON:$GNUBIN_DIR:$BREW_GEMS:$BREW_RUBY:$BREW_BIN:$BREW_SBIN:$PATH" +fi + +export PATH="$LOCAL_BIN:$PYTHON_38:$COMPOSER_DIR:$PATH" +export HIST_STAMPS="yyyy-mm-dd" export NVM_DIR="$HOME/.nvm" export NVM_LAZY_LOAD=true export NVM_COMPLETION=true export NVM_AUTO_USE=true +[ -s "/opt/homebrew/opt/nvm/nvm.sh" ] && \. "/opt/homebrew/opt/nvm/nvm.sh" +[ -s "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" ] && \. "/opt/homebrew/opt/nvm/etc/bash_completion.d/nvm" -antigen use oh-my-zsh +[[ -f "$HOME/.dotfiles/alias" ]] && source "$HOME/.dotfiles/alias" -antigen bundle php -antigen bundle nvm -# antigen bundle ruby -antigen bundle docker -antigen bundle ssh-agent -# antigen bundle git-auto-fetch +# Try to load antigen, if present +[[ -f "$HOME/.config/antigen.zsh" ]] && source "$HOME/.config/antigen.zsh" -antigen bundle colored-man-pages -antigen bundle jreese/zsh-titles -antigen bundle zsh-users/zsh-syntax-highlighting -antigen bundle zsh-users/zsh-completions +# antigen is present +if command -v antigen &> /dev/null; then + antigen use oh-my-zsh -antigen bundle Sparragus/zsh-auto-nvm-use -antigen bundle reegnz/jq-zsh-plugin -antigen bundle MichaelAquilina/zsh-you-should-use -antigen bundle sroze/docker-compose-zsh-plugin -# antigen bundle voronkovich/phpcs.plugin.zsh -antigen bundle unixorn/autoupdate-antigen.zshplugin + antigen theme oskarkrawczyk/honukai-iterm-zsh honukai -antigen theme oskarkrawczyk/honukai-iterm-zsh honukai + antigen bundle ssh-agent + antigen bundle colored-man-pages + antigen bundle jreese/zsh-titles + antigen bundle zsh-users/zsh-syntax-highlighting + antigen bundle zsh-users/zsh-completions + antigen bundle MichaelAquilina/zsh-you-should-use + antigen bundle unixorn/autoupdate-antigen.zshplugin + # antigen bundle git-auto-fetch -# Platform dependant bundles -if [[ $(uname) == 'Linux' ]] -then - antigen bundle command-not-found -elif [[ $(uname) == 'Darwin' ]] -then - # Only enable brew plugin if brew exists - hash brew 2>/dev/null && antigen bundle brew + hash php 2>/dev/null && antigen bundle php + hash nvm 2>/dev/null && antigen bundle nvm + hash docker 2>/dev/null && antigen bundle docker + + hash nvm 2>/dev/null && antigen bundle Sparragus/zsh-auto-nvm-use + hash jq 2>/dev/null && antigen bundle reegnz/jq-zsh-plugin + hash docker-compose 2>/dev/null && antigen bundle sroze/docker-compose-zsh-plugin + # antigen bundle voronkovich/phpcs.plugin.zsh + + # Platform dependant bundles + if [[ $(uname) == 'Linux' ]]; then + antigen bundle command-not-found + elif [[ $(uname) == 'Darwin' ]]; then + # If we have brew installed + if command -v brew &> /dev/null; then + # Only enable brew plugin if brew exists + antigen bundle brew + # load Z + [[ -f "$(brew --prefix z)/etc/profile.d/z.sh" ]] && source "$(brew --prefix z)/etc/profile.d/z.sh" + fi + fi + + antigen apply fi -antigen apply +# op (1Password cli) is present +if hash op 2>/dev/null; then + eval "$(op completion zsh)"; compdef _op op +fi -export HIST_STAMPS="yyyy-mm-dd" - -# Only load 1Password cli completions if op exists -hash op 2>/dev/null && eval "$(op completion zsh)"; compdef _op op - -source "$HOME/.alias" - -GCLOUD_INSTALL_LOCATION=$(gcloud info --format="value(installation.sdk_root)" --quiet) - -source "$GCLOUD_INSTALL_LOCATION/path.zsh.inc" -source "$GCLOUD_INSTALL_LOCATION/completion.zsh.inc" -source "$(brew --prefix z)/etc/profile.d/z.sh" +# gcloud is present +if hash gcloud 2>/dev/null; then + GCLOUD_LOC=$(gcloud info --format="value(installation.sdk_root)" --quiet) + [[ -f "$GCLOUD_LOC/path.zsh.inc" ]] && builtin source "$GCLOUD_LOC/path.zsh.inc" + [[ -f "$GCLOUD_LOC/completion.zsh.inc" ]] && builtin source "$GCLOUD_LOC/completion.zsh.inc" +fi # Fig post block. Keep at the bottom of this file. [[ -f "$HOME/.fig/shell/zshrc.post.zsh" ]] && builtin source "$HOME/.fig/shell/zshrc.post.zsh"