From 12083d04583d2b9c155123aa736e577dc75a4629 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 2 Jul 2023 23:23:06 +0200 Subject: [PATCH] refactor: moved dotfile examples to the correct folder, added new ones --- examples/Brewfile | 3 +- examples/dotfiles/.Brewfile | 1 + examples/{ => dotfiles}/.azure/config | 0 examples/dotfiles/.bash_profile | 25 ++ examples/dotfiles/.bashrc | 247 ++++++++++++++++++ .../dotfiles/.config/chezmoi/.chezmoi.yaml | 19 ++ .../.config/git/config} | 4 +- examples/dotfiles/.config/pip/pip.conf | 15 ++ examples/dotfiles/.gitconfig | 1 + examples/dotfiles/.gnupg/gpg-agent.conf | 7 + examples/dotfiles/.gnupg/gpg.conf | 3 + examples/dotfiles/.gnupg/sshcontrol | 18 ++ examples/dotfiles/.inputrc | 24 ++ examples/dotfiles/.kube/config | 26 ++ examples/{ => dotfiles}/.oci/config | 0 examples/dotfiles/.screenrc | 15 ++ examples/{ => dotfiles}/.tmux.conf | 0 examples/{ => dotfiles}/.tool-versions | 0 examples/dotfiles/.vimrc | 113 ++++++++ examples/dotfiles/.zshenv | 94 +++++++ examples/dotfiles/.zshrc | 186 +++++++++++++ 21 files changed, 798 insertions(+), 3 deletions(-) create mode 100644 examples/dotfiles/.Brewfile rename examples/{ => dotfiles}/.azure/config (100%) create mode 100644 examples/dotfiles/.bash_profile create mode 100644 examples/dotfiles/.bashrc create mode 100644 examples/dotfiles/.config/chezmoi/.chezmoi.yaml rename examples/{.gitconfig => dotfiles/.config/git/config} (98%) create mode 100644 examples/dotfiles/.config/pip/pip.conf create mode 100644 examples/dotfiles/.gitconfig create mode 100644 examples/dotfiles/.gnupg/gpg-agent.conf create mode 100644 examples/dotfiles/.gnupg/gpg.conf create mode 100644 examples/dotfiles/.gnupg/sshcontrol create mode 100644 examples/dotfiles/.inputrc create mode 100644 examples/dotfiles/.kube/config rename examples/{ => dotfiles}/.oci/config (100%) create mode 100644 examples/dotfiles/.screenrc rename examples/{ => dotfiles}/.tmux.conf (100%) rename examples/{ => dotfiles}/.tool-versions (100%) create mode 100644 examples/dotfiles/.vimrc create mode 100644 examples/dotfiles/.zshenv create mode 100644 examples/dotfiles/.zshrc diff --git a/examples/Brewfile b/examples/Brewfile index 3cfdf46..0d15c98 100644 --- a/examples/Brewfile +++ b/examples/Brewfile @@ -1,6 +1,7 @@ ################################################################################ -## ~/.Brewfile +## ./Brewfile or ~/.Brewfile ## +## If ~/.Brewfile, used as global file for homebrew. ## Gotchas: ## - `moreutils` installs its own old version of parallel, which conflicts with ## the `parallel` formula; install `gettext`, `parallel` and `sponge` instead diff --git a/examples/dotfiles/.Brewfile b/examples/dotfiles/.Brewfile new file mode 100644 index 0000000..e54da1f --- /dev/null +++ b/examples/dotfiles/.Brewfile @@ -0,0 +1 @@ +# See Brewfile. diff --git a/examples/.azure/config b/examples/dotfiles/.azure/config similarity index 100% rename from examples/.azure/config rename to examples/dotfiles/.azure/config diff --git a/examples/dotfiles/.bash_profile b/examples/dotfiles/.bash_profile new file mode 100644 index 0000000..e38c23b --- /dev/null +++ b/examples/dotfiles/.bash_profile @@ -0,0 +1,25 @@ +################################################################################ +## ~/.bash_profile +## +## There are 3 different types of shells in Bash: +## - the login shell; +## - the interactive non-login shell; +## - the non-interactive non-login shell. +## Login shells read /etc/profile, and only the first one found between +## '~/.bash_profile', '~/.bash_login' and '~/.profile' in this order. +## Interactive non-login shells read /etc/bashrc and ~/.bashrc. +## Non-interactive non-login shell read the file which name is the value of the +## '$BASH_ENV' variable. +## In this setup, ~/.bash_profile sources ~/.bashrc, which means that all +## changes made here will also take effect in a login shell. +## +## This file is sourced by all Bash *login* shells on startup. +################################################################################ + +# Load the user's interactive settings. +# This lines are recommended by the Bash info pages. +: "${BASHRC=$HOME/.bashrc}" +if [[ -r "$BASHRC" ]] +then + source "$BASHRC" +fi diff --git a/examples/dotfiles/.bashrc b/examples/dotfiles/.bashrc new file mode 100644 index 0000000..c7c3f72 --- /dev/null +++ b/examples/dotfiles/.bashrc @@ -0,0 +1,247 @@ +################################################################################ +## ~/.bashrc +## +## There are 3 different types of shells in Bash: +## - the login shell; +## - the interactive non-login shell; +## - the non-interactive non-login shell. +## Login shells read '/etc/profile', and only the first one found between +## '~/.bash_profile', '~/.bash_login' and '~/.profile' in this order. +## Interactive non-login shells read '/etc/bashrc' and '~/.bashrc'. +## Non-interactive non-login shells read the file which name is the value of the +## '$BASH_ENV' variable. +## In this setup, '~/.bash_profile' sources '~/.bashrc', which means that all +## changes made here will also take effect in a login shell. +## +## This file is sourced by all *interactive* Bash shells on startup, including +## some apparently interactive shells such as `scp` and `rcp` which can't +## tolerate any output. +## Make sure this doesn't display anything or bad things will happen! +## +## It is recommended to put language settings in '~/.bash_profile', +## '~/.bash_login' or '~/.profile' rather than here, as multilingual X sessions +## would not work properly if '$LANG' is overridden in every subshell. +## +## References: +## - https://www.gnu.org/software/bash/manual/html_node/The-Shopt-Builtin.html +################################################################################ + +# Automatically logout after 60 minutes of inactivity. +export TMOUT="3600" + +######################################## +# Ensure primary XDG variables are set. +######################################## + +: "${XDG_CONFIG_HOME:=${HOME}/.config}" +: "${XDG_CACHE_HOME:=${HOME}/.cache}" +: "${XDG_DATA_HOME:=${HOME}/.local/share}" +: "${XDG_STATE_HOME:=${HOME}/.local/state}" +: "${XDG_DATA_DIRS:=/usr/local/share:/usr/share}" +: "${XDG_CONFIG_DIRS:=/etc/xdg}" + +######################################## +# Ensure PATH contains common binary directories. +# Prefer user's and local paths. +######################################## + +export PATH="/Users/user/.local/bin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:$PATH" + +######################################## +# Basic utility aliases and functions. +# +# Used to simplify checks later. +# Needed in all shells. +# Ordered alphabetically and by dependencies. +######################################## + +alias disable-xtrace='set +o xtrace' +alias enable-xtrace='set -o xtrace' + +# Print the whole current environment. +alias printallenv='set -o posix && set' + +is-symlink-broken () { [[ ! -e "$1" ]] ; } + +is-shell-interactive () { + # From Bash's manpage: + # '$PS1' is set and '$-' includes 'i' if the shell is interactive. + + [[ $- =~ i ]] || [[ -t 0 ]] +} + +is-shell-login () { + # From Bash's manpage: + # A login shell is one whose first character of argument zero is a '-', or + # one started with the '--login' option. + + [[ $0 =~ ^- ]] || [[ $(shopt login_shell | cut -f 2) == 'on' ]] +} + +to-lower () { + # Bash3 has no built-in means to convert case of a string, fallback to `tr`. + echo "$(echo "$1" | tr '[:upper:]' '[:lower:]')" +} + +to-upper () { + # Bash3 has no built-in means to convert case of a string, fallback to `tr`. + echo "$(echo "$1" | tr '[:lower:]' '[:upper:]')" +} + +is-true () { + # Needs to return 0 or 1 and not `true` or `false`. + # Input's case is lowered to save on match options. + + local LOWERED_INPUT="$(to-lower "$1")" + [[ "$LOWERED_INPUT" =~ ^1|on|true|yes$ ]] +} + +# If this is a non-interactive shell, do nothing else. +# There is no need to set anything past this point for scp and rcp, and it's +# important to refrain from outputting anything in those cases. +is-shell-interactive || return + +######################################## +# Shell configuration. +######################################## + +# Check the window size of the current terminal window after each command. +# If necessary, update the values of the LINES and COLUMNS variables. +shopt -s checkwinsize + +# If Readline is being used, do not attempt to search PATH for possible +# completions when the line is empty and wait a long time for this. +shopt -s no_empty_cmd_completion + +# Add "/" to links to directories in autocompletion. +set mark-symlinked-directories on + +#################### +# History management. +#################### + +# Erase duplicates and ignore lines starting with spaces. +HISTCONTROL="ignorespace:erasedups" + +# Number of lines or commands allowed in the history file. +HISTFILESIZE=100000 + +# Number of lines or commands stored in memory as the history of the current +# session. +HISTSIZE=50000 + +# Format how the history's entries are stored. +HISTTIMEFORMAT="%Y-%m-%d %T " + +# Attempt to save all lines of a multi-line command in the same history entry. +# This allows easy re-editing of such commands. +shopt -s cmdhist + +# Append the history entries in memory to the HISTFILE when exiting the shell, +# rather than just overwriting the file. +shopt -s histappend + +# If readline is being used, load the results of history substitution into the +# editing buffer, allowing further modification before execution. +shopt -s histverify + +######################################## +# Utility aliases and functions. +# +# Ordered and grouped by dependencies. +######################################## + +alias decomment='grep -Ev "^#|^$"' +alias redo='$(history -p !!)' + +alias please='sudo' +alias sedo='sudo redo' + +ask-for-confirmation () { + is-true "$DEBUG" && enable-xtrace + + read -p 'Continue? ' REPLY + + if ! is-true "$REPLY" + then + echo "aborting" + return 1 + fi + + local RETURN_VALUE=$? + is-true "$DEBUG" && disable-xtrace + return $RETURN_VALUE +} + +swap () { + is-true "$DEBUG" && enable-xtrace + + if [[ ! $# -eq 2 ]] + then + echo "Usage: $0 file1 file2" + echo "Example: $0 /etc/resolv.conf resolv.new" + return 1 + fi + + local TMPFILE="tmp.$$" + mv "$1" "$TMPFILE" + mv "$2" "$1" + mv "$TMPFILE" "$2" + + local RETURN_VALUE=$? + is-true "$DEBUG" && disable-xtrace + return $RETURN_VALUE +} + +######################################## +# Applications settings and shortcuts. +######################################## + +# Set the default editor. +export EDITOR="/usr/bin/vim" + +# Enable colors. +alias grep='grep --color=always' +alias ls='ls -G' + +#################### +# GnuPG. +#################### + +# Integrate with the SSH agent. +export SSH_AUTH_SOCK="$(/opt/homebrew/bin/gpgconf --list-dirs 'agent-ssh-socket')" +/opt/homebrew/bin/gpgconf --launch 'gpg-agent' + +# Integrate with Pinentry. +export GPG_TTY="$(tty)" + +#################### +# SSH. +#################### + +alias ssh-load-keys='eval `ssh-agent` && ssh-add' + +#################### +# Kubernetes. +#################### + +alias kubectl-current-context='kubectl config current-context' + +kubectl-decode () { echo "$1" | base64 -d ; } +kubectl-encode () { echo -n "$1" | base64 ; } + +kubectl-nodes-with-issues () { + kubectl get nodes -o jsonpath='{.items[]}' \ + | jq ' + { + "node": .metadata.name, + "issues": [ + .status.conditions[] | select( + .status != "False" and + .type != "Ready" + ) + ] + } | select( .issues|length > 0 ) + ' - +} +alias kubectl-nodes-with-issues-in-yaml='kubectl-nodes-with-issues | yq -y "." -' diff --git a/examples/dotfiles/.config/chezmoi/.chezmoi.yaml b/examples/dotfiles/.config/chezmoi/.chezmoi.yaml new file mode 100644 index 0000000..0159871 --- /dev/null +++ b/examples/dotfiles/.config/chezmoi/.chezmoi.yaml @@ -0,0 +1,19 @@ +################################################################################ +## ~/.config/chezmoi/.chezmoi.yaml +## +## Chezmoi configuration file in one of the supported formats (JSON, JSONC, +## TOML, and YAML). +## If multiple configuration file formats are present, chezmoi will report an +## error. +## +## Sources: +## - https://www.chezmoi.io/reference/configuration-file/ +################################################################################ + +data: + email: user.name@example.com + hashedHostname: "965415361" +encryption: gpg +git: + autoPush: true +sourceDir: /home/user/.dotfiles diff --git a/examples/.gitconfig b/examples/dotfiles/.config/git/config similarity index 98% rename from examples/.gitconfig rename to examples/dotfiles/.config/git/config index 4314cac..4c191c0 100644 --- a/examples/.gitconfig +++ b/examples/dotfiles/.config/git/config @@ -1,5 +1,5 @@ ################################################################################ -## ~/.gitconfig +## ~/.config/git/config or ~/.gitconfig ## ## Global git configuration file. Settings in here override the system's ones, ## and are in turn overridden by the repositories' local ones. @@ -123,4 +123,4 @@ [commit] gpgSign = true [user] - signingKey = 99C324BA + signingKey = 89C324BA diff --git a/examples/dotfiles/.config/pip/pip.conf b/examples/dotfiles/.config/pip/pip.conf new file mode 100644 index 0000000..ed1bf6f --- /dev/null +++ b/examples/dotfiles/.config/pip/pip.conf @@ -0,0 +1,15 @@ +################################################################################ +## ~/.config/pip/pip.conf +## +## Sources: +## - https://pip.pypa.io/en/stable/topics/configuration/ +################################################################################ + +[global] +timeout = 60 +index-url = https://download.zope.org/ppix +no-cache-dir = false + +[install] +no-compile = no +no-warn-script-location = false diff --git a/examples/dotfiles/.gitconfig b/examples/dotfiles/.gitconfig new file mode 100644 index 0000000..aba22d8 --- /dev/null +++ b/examples/dotfiles/.gitconfig @@ -0,0 +1 @@ +# See ~/.config/git/config. diff --git a/examples/dotfiles/.gnupg/gpg-agent.conf b/examples/dotfiles/.gnupg/gpg-agent.conf new file mode 100644 index 0000000..1206553 --- /dev/null +++ b/examples/dotfiles/.gnupg/gpg-agent.conf @@ -0,0 +1,7 @@ +################################################################################ +## ~/.gnupg/gpg-agent.conf +################################################################################ + +default-cache-ttl 600 +enable-ssh-support +max-cache-ttl 7200 diff --git a/examples/dotfiles/.gnupg/gpg.conf b/examples/dotfiles/.gnupg/gpg.conf new file mode 100644 index 0000000..b9ae798 --- /dev/null +++ b/examples/dotfiles/.gnupg/gpg.conf @@ -0,0 +1,3 @@ +auto-key-retrieve +no-emit-version +default-key 7425E3348BAB159F4DBD1B9C9C74759518CB109F diff --git a/examples/dotfiles/.gnupg/sshcontrol b/examples/dotfiles/.gnupg/sshcontrol new file mode 100644 index 0000000..0a58403 --- /dev/null +++ b/examples/dotfiles/.gnupg/sshcontrol @@ -0,0 +1,18 @@ +################################################################################ +## ~/.gnupg/sshcontrol +## +## List of allowed ssh keys. +## Only keys present in this file are used in the SSH protocol. +## The ssh-add tool may add new entries to this file to enable them; you may +## also add them manually. +## Comment lines, like this one, as well as empty lines are ignored. Lines do +## have a certain length limit but this is not serious limitation as the format +## of the entries is fixed and checked by gpg-agent. A non-comment line starts +## with optional white spaces, followed by the key grip of the key given as 40 +## hex digits, optionally followed by a caching TTL in seconds, and another +## optional field for arbitrary flags. +## Prepend the key grip with an '!' mark to disable it. +################################################################################ + +0123456789ABCDEF0123456789ABCDEF01234567 +FEDCBA9876543210FEDCBA9876543210FEDCBA98 0 diff --git a/examples/dotfiles/.inputrc b/examples/dotfiles/.inputrc new file mode 100644 index 0000000..b139e35 --- /dev/null +++ b/examples/dotfiles/.inputrc @@ -0,0 +1,24 @@ +################################################################################ +## ~/.inputrc +## +## Control the behavior of the readline library, used e.g. by Bash in its +## interactive mode for line editing. +## +## This file is NOT used by ZSH. +################################################################################ + +# The bell style used e.g. on error or tab completion, possible values +# are `none', `visible', and `audible' the ringing the bell. +# set bell-style none + +# If set to on, words which have more than one possible completion without +# any possible partial completion cause the matches to be listed immediately +# instead of ringing the bell. +# set show-all-if-unmodified on + +# If set to on, words which have more than one possible completion cause the +# matches to be listed immediately instead of ringing the bell. +# set show-all-if-ambiguous on + +# If set to on, disable case sensitivity for completion purposes. +set completion-ignore-case on diff --git a/examples/dotfiles/.kube/config b/examples/dotfiles/.kube/config new file mode 100644 index 0000000..cdcf003 --- /dev/null +++ b/examples/dotfiles/.kube/config @@ -0,0 +1,26 @@ +################################################################################ +## ~/.kube/config +## +## Sources: +## - https://kubernetes.io/docs/concepts/configuration/organize-cluster-access-kubeconfig/ +################################################################################ + +apiVersion: v1 +clusters: +- cluster: + certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURBTkJna3Foa2lHOVcwQkFRc0ZBREFWTVJNd0VRWURWUVFERXdwcmRXSmwKY201bGRHVnpNQjRYRFRJeU1URXhNakV6TWpBME5sb1hEVE15TVRFd09URXpNakEwTmxvd0ZURVRNQkVHQTFVRQpBeE1LYTNWaVpYSnVaWFJsY3pDQ0FTSXdEUVlKS29aSWh2Y05BUUVCQlFBRGdnRVBBRENDQVFvQ2dnRUJBTlZyCnQ3eUtZQkp1eVUvaGY0TTJOc0pzVFBxeENPYktDYUl0UmR4SGs3akJRM2lBRENadHVQZk9EbWZpaG9MUzR0REoKcVZvVlh4dTlzRXhVM0FpSmppWHpNaXlCbVJWM3Q1TWcvUUJQWGdpbk4wUWdLLcFyVGQ3L2pIb0ZwSEN4UzhmbwpKWmxQaVhnQk1LQ3puR0I3UWJmUWFkVG9JUC9jU2Z3OXBDZzVZZUxET3ppMk0rOU1yZlhKSFRVamFXNUlIb2o0CnJGNnZZS3dkdy84WEdvRlZOVUZ6SXI4c3dTbTNQdHRqYm5PRmtuMkRWT01yTEM1QmsrQnVKMVFWcUpKUnJhTXMKbHk2WGl4M2dRZ2sydXZ3NU1UNXBkNCtqNXlCekpoOXlwTVRleG1CVFZTbzIrN2hpSEtPSS8rVXlhckVZOWRvdgo0TzFjaFEvZ3NVQzV3RzB1UVU4Q0F3RUFBYU5aTUZjd0RnWURWUjBQQVFIL0JBUURBZ0trTUE4R0ExVWRFd0VCCi93UUZNQU1CQWY4d0hRWURWUjBPQkJZRUZOb0Eybkd2dTUxNnBBNGllN05BNEF3a1p2ZGxNQlVHQTFVZEVRUU8KTUF6q7NtdDFZbVZ5Ym1WMFpYTXdEUVlKS29aSWh2Y05BUUVMQlFBRGdnRUJBS0ZOU3pIVkpzTzJZYVg4djJXLwppVG56UHFweDZLRDFjQnptZGxVTk5LblNLendhOWxscmVwTldpVUJuOXFZVmdlQ0Y0VUpEVGpSK2tuS3owdmVwCnZUWG1ReXpXaThVQ0p3bXo0RjR2UWlBSEdHb1U1UEVIMW5lb0RlRXU5ZTNvdStuVzV2SmYzRDEzb3ZjUFhseWkKak1JRzNaWndVTkJYMjF6SHdZaFhjd3pIZEN0dxBrcmVTRW9hY0x5UW5XL1lGZ0ZtcXZQOXExRVRDNXFHQlZycgpPeFZyOFFNZ1Npdk1wcXpXVkl1eElPM1FOWjhIWnJUenZvNDdrS1JuZFFqcE9UK09nNGNEWkVkZDBWT0pZQzREClFrVXJNSDlCcVNyUWdLejRLTGtqN2NWaDFQWUZmSnRubHpWWFlKeENtVWtZc3tvbWh6NkZSOGpPSG4ITUUwcjYKcDJnPQotLS6tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg== + server: https://kubernetes.docker.internal:6443 + name: docker-desktop +contexts: +- context: + cluster: docker-desktop + user: docker-desktop + name: docker-desktop +current-context: docker-desktop +kind: Config +preferences: {} +users: +- name: docker-desktop + user: + client-certificate-data: LS0tLS1CRUdJTiBDRVJUSUZJQ9FURS0tLS0tCk1JSURPakNDqWlxZ2F3SUJBZ0lJVnIyeUwxQjlzLzR3RFFZSktvWklodmNOQVFFTEJRQXdGVEVUTUJFR0ExVUUKQXhNS2EzVmlaWEp1WlhSbGN6QWVGdzB5TWpFeE1USXhNekl3TkRaYUZ3MHlOREEyTURJeU1ERXpNVGhhTURZeApGekFWQmdOVkJBb1REbk41YzNSbGJUcHRZWE4wWlhKek1Sc3dHUVlEVlFRREV4SmtiMk5yWlhJdFptOXlMV1JsCmMydDBiM0F352dFaU1BM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EbkJNdEdSMmJTRTdJQVVaaERGWDExTFR6NmV1QVBEWEJ4RE96ZUxDQWF3CkZRVjlYTUVDZ1lCa0FON1ZYZ2RrQnRtT2JHZXUvbkJZcnpibGRkTmgwUjRHbUNjSjlHNmtSYlFzNEpkWEhtMC8KM0J0dzVSUS9LWHFNaHV6elNhSnBHdUJEcy9Td1BhU09abTNtOTRFbHpIcnQ2UnJ3cWRxWUE0SnI3dk1ZOEVKdwpDYUd0MVVjN2lId0tCZ1lHdzJ6cHA5V2s1aTNzQ01lRkpScWNoV2tiRWxEYTU5VThUcm5Qdnc9PQotLS0tLUVORCBSU0EgUFJJVkFURSBLRVktLS0tLQo= diff --git a/examples/.oci/config b/examples/dotfiles/.oci/config similarity index 100% rename from examples/.oci/config rename to examples/dotfiles/.oci/config diff --git a/examples/dotfiles/.screenrc b/examples/dotfiles/.screenrc new file mode 100644 index 0000000..a03b078 --- /dev/null +++ b/examples/dotfiles/.screenrc @@ -0,0 +1,15 @@ +################################################################################ +## ~/.screenrc +################################################################################ + +defscrollback 1000000 +hardstatus alwayslastline +hardstatus string '%{gk}[%{G}%H%{g}][%= %{wk}%?%-Lw%?%{=b kR}(%{W}%n*%f %t%?(%u)%?%{=b kR})%{= kw}%?%+Lw%?%?%= %{g}]%{=b C}[%m/%d/%y %C %A]%{W}' +logfile flush +logtstamp after 1 +logtstamp on +shell -$SHELL +startup_message off +termcapinfo xterm ti@:te@ +termcapinfo xterm-color ti@:te@ +vbell off diff --git a/examples/.tmux.conf b/examples/dotfiles/.tmux.conf similarity index 100% rename from examples/.tmux.conf rename to examples/dotfiles/.tmux.conf diff --git a/examples/.tool-versions b/examples/dotfiles/.tool-versions similarity index 100% rename from examples/.tool-versions rename to examples/dotfiles/.tool-versions diff --git a/examples/dotfiles/.vimrc b/examples/dotfiles/.vimrc new file mode 100644 index 0000000..ca76d69 --- /dev/null +++ b/examples/dotfiles/.vimrc @@ -0,0 +1,113 @@ +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +"" ~/.vimrc +"" +"" Sources: +"" - http://vimdoc.sourceforge.net/htmldoc/filetype.html +"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + +" Attempt to determine the type of a file based on its name and possibly its +" contents. +" Allow intelligent auto-indenting for each filetype, and for plugins that are +" filetype specific. +filetype indent plugin on + +" Enable syntax highlighting. +syntax on + +" Display line numbers on the left-hand side. +set number + +" Highlight the line underneath the cursor. +set cursorline + +" Highlight the column underneath the cursor. +" set cursorcolumn + +" Highlight matching brackets. +set showmatch + +" Show typed partial commands in the last line of the screen. +set showcmd + +" Show the mode you are on the last line. +" set showmode + +" Display the cursor position on the last line of the screen or in the status +" line of a window. +set ruler + +" Use visual bell instead of beeping when doing something wrong. +set visualbell + +" Raise a dialogue asking if you wish to save changed files instead of failing a +" command because of unsaved changes. +set confirm + +" Do not redraw the screen during important tasks. +" Leads to smoother and faster macros. +set lazyredraw + +"""""""""""""""""""""""""""""""""""""""" +" Search. +"""""""""""""""""""""""""""""""""""""""" + +" Ignore capital letters during search. +set ignorecase + +" Override the ignorecase option if searching for capital letters. +" This allows to search specifically for capital letters. +set smartcase + +" Highlight during a search. +set hlsearch + +" Highlight matching characters as you type while searching though a file +" incrementally. +set incsearch + +" Show matching words during a search. +set showmatch + +"""""""""""""""""""""""""""""""""""""""" +" Indentation. +"""""""""""""""""""""""""""""""""""""""" + +" Copy indentation from the current line when starting a new line +set autoindent + +" Adjust indentation on special events (e.g. after a bracket start) +set smartindent + +" Insert spaces instead of a tab +set expandtab + +" Draw a tab as 4 spaces +set tabstop=4 + +" Number of spaces to use for each (auto)indent step +set shiftwidth=4 + +" Number of spaces the cursor moves right when a Tab is inserted and moves left +" when Backspace is used to erase a tab. +" A negative value sets it to fall back to the value of 'shiftwidth' +set softtabstop=-1 + +" Overrides for shell files +" Use tabs for indentation instead of spaces +autocmd Filetype sh setlocal softtabstop=0 noexpandtab + +"""""""""""""""""""""""""""""""""""""""" +" Line wrap +"""""""""""""""""""""""""""""""""""""""" + +" Paint the background of the 81st character to draw a vertical indicator. +set colorcolumn=81 + +" Make it black in Graphical Vim. +" See :help gui-colors for a list of suggested color names. +" See :help guibg for how to specify specific rgb/hex colors. +highlight ColorColumn guibg=Black + +" Make it dark grey in terminal vim. +" See :help cterm-colors for a list of colors that can be used in the terminal. +highlight ColorColumn ctermbg=DarkGrey diff --git a/examples/dotfiles/.zshenv b/examples/dotfiles/.zshenv new file mode 100644 index 0000000..3f3ac8c --- /dev/null +++ b/examples/dotfiles/.zshenv @@ -0,0 +1,94 @@ +################################################################################ +## ~/.zshenv +## +## This file is sourced by *all* zsh shells on startup. +################################################################################ + +######################################## +# Ensure primary XDG variables are set. +######################################## + +: "${XDG_CONFIG_HOME:=${HOME}/.config}" +: "${XDG_CACHE_HOME:=${HOME}/.cache}" +: "${XDG_DATA_HOME:=${HOME}/.local/share}" +: "${XDG_STATE_HOME:=${HOME}/.local/state}" +: "${XDG_DATA_DIRS:=/usr/local/share:/usr/share}" +: "${XDG_CONFIG_DIRS:=/etc/xdg}" + +######################################## +# Basic utility aliases and functions. +# +# Used to simplify checks later. +# Needed in all shells. +# Ordered alphabetically and by dependencies. +######################################## + +alias disable-xtrace='unsetopt xtrace' +alias enable-xtrace='setopt xtrace' +alias is-shell-interactive='[[ -o interactive ]]' +alias is-shell-login='[[ -o login ]]' + +# Print the whole current environment. +alias printallenv='setopt posixbuiltins && set' + +to-lower () { + echo "${1:l}" +} + +to-upper () { + echo "${1:u}" +} + +is-true () { + # Needs to return 0 or 1 and not `true` or `false`. + # Input's case is lowered to save on match options. + + local LOWERED_INPUT="$(to-lower "$1")" + [[ "$LOWERED_INPUT" =~ '^1|on|true|yes$' ]] +} + +# Make PATHs' entries unique for better performances. +typeset -aU {f,info,man,}path + +######################################## +# Shell configuration. +# +# https://zsh.sourceforge.io/Doc/Release/Options.html +######################################## + +# Require 'cd' to change directory. +unsetopt auto_cd + +######################################## +# Utility aliases and functions. +# +# Ordered and grouped by dependencies. +######################################## + +alias decomment='grep -Ev "^#|^$"' + +alias please='sudo' + +######################################## +# Applications' settings and shortcuts. +######################################## + +#################### +# Python. +#################### + +# See also: +# - https://docs.python.org/3/using/cmdline.html#environment-variables + +PYTHONCACHE=1 + +#################### +# GnuPG. +#################### + +# Integrate with the SSH agent. +export SSH_AUTH_SOCK="$(/opt/homebrew/bin/gpgconf --list-dirs 'agent-ssh-socket')" +/opt/homebrew/bin/gpgconf --launch 'gpg-agent' + +# Integrate with Pinentry. +export GPG_TTY="$(tty)" diff --git a/examples/dotfiles/.zshrc b/examples/dotfiles/.zshrc new file mode 100644 index 0000000..d4bae02 --- /dev/null +++ b/examples/dotfiles/.zshrc @@ -0,0 +1,186 @@ +################################################################################ +## ~/.zshrc +## +## This file is sourced by all *interactive* zsh shells on startup, including +## some apparently interactive shells such as scp and rcp that can't tolerate +## any output. +## Make sure this doesn't display anything or bad things will happen! +## +## It is recommended to make language settings in ~/.zprofile rather than here, +## since multilingual X sessions would not work properly if LANG is overridden +## in every subshell. +################################################################################ + +# Enable this and the last line to debug performance. +# zmodload zsh/zprof + +######################################## +# Shell configuration. +# Sane defaults that could easily be overridden later. +######################################## + +# If a pattern for filename generation has no matches, print an error instead of +# leaving it unchanged in the argument list. +# This also applies to file expansion of an initial '~' or '='. +setopt no_match + +# Treat '#' as a comment starter instead of matching patterns. +setopt interactive_comments + +# Remind compinstall where it wrote zstyle statements last time. +# This lets one run compinstall again to update them. +zstyle ':compinstall' filename ~/.zshrc + +# Automatically update completions after PATH changes. +zstyle ':completion:*' rehash true + +# Enable cache for completions. +zstyle ':completion:*' use-cache true + +# Load extensions. +autoload -Uz bashcompinit compinit promptinit + +# Enable completions. +bashcompinit +compinit + +# Enable prompt management. +promptinit + +# Automatically logout after 60 minutes of inactivity. +export TMOUT="3600" + +#################### +# History management. +#################### + +# The file to save the history into when an interactive shell exits. +# If unset, the history is not saved. +: "${HISTFILE:=$HOME/.zsh_history}" + +# Set the number of lines or commands allowed in the history file +SAVEHIST=50000 + +# Set the number of lines or commands stored in memory as history list during an +# ongoing session +HISTSIZE=100000 + +# Append the session's history list to the history file, rather than replace it. +# Multiple parallel sessions will all have the new entries from their history +# lists added to the history file, in the order that they exit. The file will +# still be periodically re-written to trim it when the number of lines grows 20% +# beyond the value specified by $SAVEHIST +setopt append_history + +# When searching for history entries in the line editor, do not display +# duplicates of a line previously found +# setopt hist_find_no_dups + +# If a new command line being added to the history list duplicates an older one, +# the older command is removed from the list +setopt hist_ignore_all_dups + +# Remove command lines from the history list when the first character on the +# line is a space, or when one of the expanded aliases contains a leading space. +# Only normal aliases (not global or suffix aliases) have this behavior. Note +# that the command lingers in the internal history until the next command is +# entered before it vanishes, allowing you to briefly reuse or edit the line. +# If you want to make it vanish right away without entering another command, +# type a space and press return +setopt hist_ignore_space + +# Remove superfluous blanks from each command line being added to the history +setopt hist_reduce_blanks + +# Omit older commands duplicating newer ones when writing out the history file +# setopts hist_save_no_dups + +# Whenever the user enters a line with history expansion, perform history +# expansion and reload the line into the editing buffer instead of executing it +setopt hist_verify + +######################################## +# Utility aliases and functions. +# +# Ordered and grouped by dependencies. +######################################## + +#################### +# History management. +#################### + +alias redo='$(history -p !!)' +alias sedo='sudo $(history -p !!)' + +######################################## +# Applications settings and shortcuts. +######################################## + +# Set the default editor. +export EDITOR="/usr/bin/vim" + +# Enable colors. +alias grep='grep --color=always' +alias ls='ls -G' + +#################### +# SSH. +#################### + +alias ssh-load-keys='eval `ssh-agent` && ssh-add' + +#################### +# Kubernetes. +#################### + +alias kubectl-current-context='kubectl config current-context' + +kubectl-decode () { echo "$1" | base64 -d ; } +kubectl-encode () { echo -n "$1" | base64 ; } + +kubectl-nodes-with-issues () { + kubectl get nodes -o jsonpath='{.items[]}' \ + | jq ' + { + "node": .metadata.name, + "issues": [ + .status.conditions[] | select( + .status != "False" and + .type != "Ready" + ) + ] + } | select( .issues|length > 0 ) + ' - +} +alias kubectl-nodes-with-issues-in-yaml='kubectl-nodes-with-issues | yq -y "." -' + +# Reassign the expected behaviour to the delete, end and home keys. +bindkey "^[[3~" delete-char +bindkey "^[[F" end-of-line +bindkey "^[[H" beginning-of-line + +######################################## +# Configuration freeze. +# Finalize customizations and try to set the current configuration immutable. +######################################## + +# Clean up PATHs. +# Remove non-existing directories, follow symlinks and clean up remaining paths. +if command which realpath >/dev/null 2>&1 +then + [[ -n "${fpath[@]}" ]] && fpath=( $(realpath -q ${fpath[@]}) ) + [[ -n "${infopath[@]}" ]] && infopath=( $(realpath -q ${infopath[@]}) ) + [[ -n "${manpath[@]}" ]] && manpath=( $(realpath -q ${manpath[@]}) ) + [[ -n "${path[@]}" ]] && path=( $(realpath -q ${path[@]}) ) +fi + +# Freeze (-f) or unfreeze (-u) the tty. When the tty is frozen, no changes made +# to the tty settings by external programs will be honored by the shell, except +# for changes in the size of the screen; the shell will simply reset the +# settings to their previous values as soon as each command exits or is +# suspended. +# Freezing the tty only causes future changes to the state to be blocked. +ttyctl -f + +# Enable this and the module inclusion on the first line to debug performance. +# zprof