From ea34757c63296ba4ca74b5ee8e6e455952f0675b Mon Sep 17 00:00:00 2001 From: Brian Zalewski Date: Tue, 22 Nov 2022 04:25:30 +0000 Subject: [PATCH] Update dotfiles/.profile, dotfiles/.local/share/chezmoi/dot_profile.tmpl, dotfiles/.local/share/chezmoi/private_dot_config/shell/exports --- .../.local/share/chezmoi/dot_profile.tmpl | 120 ++++++- .../shell/{exports.sh => exports} | 337 ++++++++---------- dotfiles/.profile | 19 +- 3 files changed, 285 insertions(+), 191 deletions(-) rename dotfiles/.local/share/chezmoi/private_dot_config/shell/{exports.sh => exports} (68%) diff --git a/dotfiles/.local/share/chezmoi/dot_profile.tmpl b/dotfiles/.local/share/chezmoi/dot_profile.tmpl index 83687089..d68663c7 100644 --- a/dotfiles/.local/share/chezmoi/dot_profile.tmpl +++ b/dotfiles/.local/share/chezmoi/dot_profile.tmpl @@ -1,4 +1,122 @@ -HOSTNAME={{- .chezmoi.hostname }} +# shellcheck disable=SC1090,SC1091 + +# Aliases / Functions / Exports +if [ -f "$XDG_CONFIG_HOME/shell/exports" ]; then + . "$XDG_CONFIG_HOME/shell/exports" +fi +if [ -f "$XDG_CONFIG_HOME/shell/aliases" ]; then + . "$XDG_CONFIG_HOME/shell/aliases" +fi +if [ -f "$XDG_CONFIG_HOME/shell/functions" ]; then + . "$XDG_CONFIG_HOME/shell/functions" +fi + +### Bash / ZSH +if [ "$BASH_SUPPORT" = 'true' ]; then + ### OS Detection + if [ -f /etc/os-release ]; then + . /etc/os-release + if [ "$ID" = 'alpine' ]; then + OS_ICON="" + elif [ "$ID" = 'arch' ]; then + OS_ICON="" + elif [ "$ID" = 'centos' ]; then + OS_ICON="" + elif [ "$ID" = 'coreos' ]; then + OS_ICON="" + elif [ "$ID" = 'debian' ]; then + OS_ICON="" + elif [ "$ID" = 'deepin' ]; then + OS_ICON="" + elif [ "$ID" = 'elementary' ]; then + OS_ICON="" + elif [ "$ID" = 'endeavour' ]; then + OS_ICON="" + elif [ "$ID" = 'freebsd' ]; then + OS_ICON="" + elif [ "$ID" = 'gentoo' ]; then + OS_ICON="" + elif [ "$ID" = 'kali' ]; then + OS_ICON="" + elif [ "$ID" = 'linuxmint' ]; then + OS_ICON="" + elif [ "$ID" = 'manjaro' ]; then + OS_ICON="" + elif [ "$ID" = 'nixos' ]; then + OS_ICON="" + elif [ "$ID" = 'openbsd' ]; then + OS_ICON="" + elif [ "$ID" = 'opensuse' ]; then + OS_ICON="" + elif [ "$ID" = 'parrot' ]; then + OS_ICON="" + elif [ "$ID" = 'pop_os' ]; then + OS_ICON="" + elif [ "$ID" = 'raspberry_pi' ]; then + OS_ICON="" + elif [ "$ID" = 'redhat' ]; then + OS_ICON="" + elif [ "$ID" = 'fedora' ]; then + OS_ICON="" + elif [ "$ID" = 'ubuntu' ]; then + OS_ICON="" + else + OS_ICON="" + fi + else + if [ -d /Applications ] && [ -d /Library ] && [ -d /System ]; then + # macOS + OS_ICON="" + else + OS_ICON="" + fi + fi + + ### ASDF + if [ -f "$ASDF_DIR/asdf.sh" ]; then + . "$ASDF_DIR/asdf.sh" + fi +fi + +### Colorize +alias grep='grep --color=auto' +alias fgrep='fgrep --color=auto' +alias egrep='egrep --color=auto' +alias diff='diff --color=auto' +alias ip='ip --color=auto' +alias pacman='pacman --color=auto' + +### Aliases (better defaults for simple commands) +alias cp='cp -v' +alias rm='rm -I' +alias mv='mv -iv' +alias ln='ln -sriv' +alias xclip='xclip -selection c' +command -v vim > /dev/null && alias vi='vim' + +### TOP - order based on preference of "top" application (last item will always be chosen if installed, e.g. glances) +command -v htop > /dev/null && alias top='htop' +command -v gotop > /dev/null && alias top='gotop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v ytop > /dev/null && alias top='ytop -p $([ "$COLOR_SCHEME" = "light" ] && echo "-c default-dark")' +command -v btm > /dev/null && alias top='btm $([ "$COLOR_SCHEME" = "light" ] && echo "--color default-light")' +# themes for light/dark color-schemes inside ~/.config/bashtop; Press ESC to open the menu and change the theme +command -v bashtop > /dev/null && alias top='bashtop' +command -v bpytop > /dev/null && alias top='bpytop' +command -v glances > /dev/null && alias top='glances' + +### Cargo +if [ -f "$CARGO_HOME/env" ]; then + . "$CARGO_HOME/env" +fi + +### SDKMan +if command -v brew > /dev/null && command -v sdkman-cli > /dev/null; then + export SDKMAN_DIR="$(brew --prefix sdkman-cli)/libexec" + . "$SDKMAN_DIR/bin/sdkman-init.sh" +elif [ -f "$SDKMAN_DIR/bin/sdkman-init.sh" ]; then + export SDKMAN_DIR="$XDG_DATA_HOME/sdkman" + . "$SDKMAN_DIR/bin/sdkman-init.sh" +fi ### VIM export GVIMINIT='let $MYGVIMRC="$XDG_CONFIG_HOME/vim/gvimrc" | source $MYGVIMRC' diff --git a/dotfiles/.local/share/chezmoi/private_dot_config/shell/exports.sh b/dotfiles/.local/share/chezmoi/private_dot_config/shell/exports similarity index 68% rename from dotfiles/.local/share/chezmoi/private_dot_config/shell/exports.sh rename to dotfiles/.local/share/chezmoi/private_dot_config/shell/exports index a8247bf6..41f16156 100644 --- a/dotfiles/.local/share/chezmoi/private_dot_config/shell/exports.sh +++ b/dotfiles/.local/share/chezmoi/private_dot_config/shell/exports @@ -1,5 +1,8 @@ #!/usr/bin/env sh +### Theme +export COLOR_SCHEME=dark + ### XDG # Source: # https://wiki.archlinux.org/index.php/XDG_Base_Directory export XDG_CONFIG_HOME="$HOME/.config" @@ -25,110 +28,21 @@ export XDG_TEMPLATES_DIR="$HOME/Templates" export XDG_PUBLICSHARE_DIR="$HOME/Public" {{- end }} -### Theme -export COLOR_SCHEME=dark -export GTK_RC_FILES="$XDG_CONFIG_HOME/gtk-1.0/gtkrc" -export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" - -{{- if eq .host.distro.family "linux" -}} -### Homebrew -if [ -d /home/linuxbrew/.linuxbrew/bin ]; then - export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew" - export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar" - export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew" - export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}" - export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:" - export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}" - export WHALEBREW_INSTALL_PATH="/home/linuxbrew/.linuxbrew/whalebrew" -fi - -{{- end }} -### Android Studio -{{- if eq .host.distro.family "darwin" -}} -if [ -d ~/Library/Android ]; then - export PATH="$PATH:~/Library/Android/sdk/cmdline-tools/latest/bin" - export PATH="$PATH:~/Library/Android/sdk/platform-tools" - export PATH="$PATH:~/Library/Android/sdk/tools/bin" - export PATH="$PATH:~/Library/Android/sdk/tools" -fi -{{- end }} -export ANDROID_SDK_HOME="$XDG_DATA_HOME/android-sdk" - ### ASDF export ASDF_CONFIG_FILE="$XDG_CONFIG_HOME/asdf/asdfrc" export ASDF_DIR="$XDG_DATA_HOME/asdf" export ASDF_DATA_DIR="$ASDF_DIR" -export ASDF_CRATE_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-cargo-pkgs" -export ASDF_GEM_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-ruby-pkgs" -export ASDF_GOLANG_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-golang-pkgs" +export ASDF_CRATE_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-cargo-pkgs +export ASDF_GEM_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-ruby-pkgs +export ASDF_GOLANG_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-golang-pkgs export ASDF_NPM_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-npm-packages" -export ASDF_PYTHON_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-python-pkgs" - -### AWS CLI -export AWS_SHARED_CREDENTIALS_FILE="$XDG_CONFIG_HOME/aws/credentials" -export AWS_CONFIG_FILE="$XDG_CONFIG_HOME/aws/config" - -### Azure CLI -export AZURE_CONFIG_DIR="$XDG_CONFIG_HOME/azure" - -### bat -export BAT_CONFIG_PATH="$XDG_CONFIG_HOME/batrc" +export ASDF_PYTHON_DEFAULT_PACKAGES_FILE="$XDG_CONFIG_HOME/asdf/default-python-pkgs ### Cargo export CARGO_HOME="$XDG_DATA_HOME/cargo" -export PATH="$PATH:$CARGO_HOME/bin" - -### Bash -export BASH_COMPLETION_USER_FILE="$XDG_CONFIG_HOME/bash-completion/bash_completion" - -### BitWarden -# https://bitwarden.com/help/cli/#using-an-api-key -# BW_CLIENTID client_id -# BW_CLIENTSECRET - -### Docker -export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker" -export MACHINE_STORAGE_PATH="$XDG_DATA_HOME/docker-machine" - -### Elastic Agent -# https://www.elastic.co/guide/en/fleet/current/agent-environment-variables.html#env-common-vars - -### ffmpeg -export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg" - -### fzf -if command -v fd > /dev/null; then - export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix --hidden --follow --exclude .git' - export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" -fi - -### Git -export GIT_MERGE_AUTOEDIT=no - -### gitfuzzy -if command -v delta > /dev/null; then - export GF_BAT_STYLE=changes - export GF_BAT_THEME=zenbur - export GF_SNAPSHOT_DIRECTORY="$XDG_DATA_HOME/git-fuzzy-snapshots" - export GF_PREFERRED_PAGER="delta --theme=gruvbox --highlight-removed -w __WIDTH__" -fi ### Go export GOPATH="$XDG_DATA_HOME/go" -export GO111MODULE=on -export PATH="$PATH:${GOPATH}/bin" -if command -v go > /dev/null && which go | grep -q 'asdf' > /dev/null && command -v asdf > /dev/null; then - GOROOT="$(asdf where golang)/go" - export GOROOT - export PATH="$PATH:${GOROOT}/bin" -elif command -v go > /dev/null && command -v brew > /dev/null; then - GOROOT="$(brew --prefix go)/libexec" - export GOROOT - export PATH="$PATH:${GOROOT}/bin" -fi - -### Gradle -export GRADLE_USER_HOME="$XDG_DATA_HOME/gradle" ### Homebrew export HOMEBREW_BUNDLE_FILE="$XDG_CONFIG_HOME/Brewfile" @@ -139,102 +53,16 @@ export HOMEBREW_CASK_OPTS="--appdir=~/Applications" ### HTTPie export HTTPIE_CONFIG_DIR="$XDG_CONFIG_HOME/httpie" -### IPFS -export IPFS_PATH="$XDG_DATA_HOME/ipfs" - -### Java -export _JAVA_OPTIONS=-Djava.util.prefs.userRoot="$XDG_CONFIG_HOME/java" - -### k9s -export K9SCONFIG="$XDG_CONFIG_HOME/k9s" - -### KDE -export KDEHOME="$XDG_CONFIG_HOME/kde" - -### Kodi -export KODI_DATA="$XDG_DATA_HOME/kodi" - -### McFly -export MCFLY_FUZZY=2 -export MCFLY_RESULTS=14 -export MCFLY_KEY_SCHEME=vim - -### minikube -export MINIKUBE_HOME="$XDG_DATA_HOME/minikube" - -### MySQL -export MYSQL_HISTFILE="$XDG_DATA_HOME/mysql_history" - -### nnn -if command -v nnn > /dev/null; then - alias n='nnn -de' - alias N='sudo -E nnn -dH' - alias nnn-install-plugins='curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh' - export NNN_RCLONE='rclone mount --read-only --no-checksum' - export NNN_SSHFS='sshfs -o reconnect,idmap=user,cache_timeout=3600' -fi - -### Node.js -export NODE_REPL_HISTORY="$XDG_DATA_HOME/node_repl_history" - ### NPM export NPM_CONFIG_USERCONFIG="$XDG_CONFIG_HOME/npm/npmrc" -### Parallels -export PARALLEL_HOME="$XDG_CONFIG_HOME/parallel" - -### Pass -export PASSWORD_STORE_DIR="$XDG_DATA_HOME/pass" - -### Poetry -export POETRY_HOME="$XDG_DATA_HOME/poetry" -export PATH="$POETRY_HOME/bin:$PATH" - -### Postgres -export PSQLRC="$XDG_CONFIG_HOME/pg/psqlrc" -export PSQL_HISTORY="$XDG_STATE_HOME/psql_history" -export PGPASSFILE="$XDG_CONFIG_HOME/pg/pgpass" -export PGSERVICEFILE="$XDG_CONFIG_HOME/pg/pg_service.conf" - -### Readline -export INPUTRC="$XDG_CONFIG_HOME/readline/inputrc" - -### Rear -# https://github.com/rear/rear/blob/master/doc/user-guide/03-configuration.adoc - -### Redis -export REDISCLI_HISTFILE="$XDG_DATA_HOME/redis/rediscli_history" -export REDISCLI_RCFILE="$XDG_CONFIG_HOME/redis/redisclirc" - -### ripgrep -export RIPGREP_CONFIG_PATH="$XDG_CONFIG_HOME/ripgrep/config" - -### Ruby -export GEM_HOME="$XDG_DATA_HOME/gems" -export PATH="$PATH:$GEM_HOME/bin" - ### Rustup export RUSTUP_HOME="$XDG_DATA_HOME/rustup" -### SDKMan -export SDKMAN_DIR="$XDG_DATA_HOME/sdkman" - -### Vagrant -export VAGRANT_ALIAS_FILE="$XDG_DATA_HOME/vagrant/aliases" -export VAGRANT_DEFAULT_PROVIDER=virtualbox -export VAGRANT_HOME="$XDG_DATA_HOME/vagrant.d" - -### Volta -export VOLTA_HOME="$XDG_DATA_HOME/volta" -export PATH="$VOLTA_HOME/bin:$PATH" - ### wget export WGETRC="$XDG_CONFIG_HOME/wget/wgetrc" -### Whalebrew -export WHALEBREW_CONFIG_DIR="$XDG_CONFIG_HOME/whalebrew" - -### Man pages +### Colorize man pages export LESS_TERMCAP_mb=$'\e[1;32m' export LESS_TERMCAP_md=$'\e[1;32m' export LESS_TERMCAP_me=$'\e[0m' @@ -243,7 +71,6 @@ export LESS_TERMCAP_so=$'\e[01;33m' export LESS_TERMCAP_ue=$'\e[0m' export LESS_TERMCAP_us=$'\e[1;4;31m' export LESSHISTFILE=- -export MANPAGER="less -X" ### Line Wrap setterm -linewrap on 2>/dev/null @@ -274,4 +101,150 @@ export BROWSER='/mnt/c/Program\ Files\ \(x86\)/Google/Chrome/Application/chrome. {{- end }} ### PATH -export PATH="$PATH:$HOME/.local/bin" +PATH="$PATH:$HOME/.local/bin:$CARGO_HOME/bin" + + +# Don’t clear the screen after quitting a manual page +export MANPAGER="less -X" +### GTK +export GTK2_RC_FILES="$XDG_CONFIG_HOME/gtk-2.0/gtkrc" + +### Homebrew +if [ -d /home/linuxbrew/.linuxbrew/bin ]; then + export HOMEBREW_PREFIX="/home/linuxbrew/.linuxbrew" + export HOMEBREW_CELLAR="/home/linuxbrew/.linuxbrew/Cellar" + export HOMEBREW_REPOSITORY="/home/linuxbrew/.linuxbrew/Homebrew" + export PATH="/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin${PATH+:$PATH}" + export MANPATH="/home/linuxbrew/.linuxbrew/share/man${MANPATH+:$MANPATH}:" + export INFOPATH="/home/linuxbrew/.linuxbrew/share/info:${INFOPATH:-}" + export WHALEBREW_INSTALL_PATH="/home/linuxbrew/.linuxbrew/whalebrew" +fi + +### Whalebrew +export WHALEBREW_CONFIG_DIR="$HOME/.config/whalebrew" + +### Go +export GOPATH="${HOME}/.local/go" +export GO111MODULE=on +export PATH="$PATH:${GOPATH}/bin" +if command -v go > /dev/null && which go | grep -q 'asdf' > /dev/null && command -v asdf > /dev/null; then + GOROOT="$(asdf where golang)/go" + export GOROOT + export PATH="$PATH:${GOROOT}/bin" +elif command -v go > /dev/null && command -v brew > /dev/null; then + GOROOT="$(brew --prefix go)/libexec" + export GOROOT + export PATH="$PATH:${GOROOT}/bin" +fi + +### Android Studio +if [ -d ~/Library/Android ]; then + export PATH="$PATH:~/Library/Android/sdk/cmdline-tools/latest/bin" + export PATH="$PATH:~/Library/Android/sdk/platform-tools" + export PATH="$PATH:~/Library/Android/sdk/tools/bin" + export PATH="$PATH:~/Library/Android/sdk/tools" +fi +export ANDROID_SDK_HOME="$HOME/.local/android-sdk" + +### Azure CLI +export AZURE_CONFIG_DIR="$HOME/.config/azure" + +### bat +export BAT_CONFIG_PATH="$HOME/.config/batrc" +if command -v bat > /dev/null; then + export MANPAGER="sh -c 'col -bx | bat -l man -p'" + alias bathelp='bat --plain --language=help' + alias cat='bat -pp' + alias less='bat --paging=always' + help() { + "$@" --help 2>&1 | bathelp + } +fi + +### BitWarden +# https://bitwarden.com/help/cli/#using-an-api-key +# BW_CLIENTID client_id +# BW_CLIENTSECRET + +### curlie +if command -v curlie > /dev/null; then + alias curl='curlie' +fi + +### Elastic Agent +# https://www.elastic.co/guide/en/fleet/current/agent-environment-variables.html#env-common-vars + +### exa +if command -v exa > /dev/null; then + alias ls='exa --long --all --color auto --icons --sort=type' + alias tree='exa --tree' + alias la='ls -la' + alias lt='ls --tree --level=2' +fi + +### fzf +if command -v fd > /dev/null; then + export FZF_DEFAULT_COMMAND='fd --type f --strip-cwd-prefix --hidden --follow --exclude .git' + export FZF_CTRL_T_COMMAND="$FZF_DEFAULT_COMMAND" +fi + +### Git +export GIT_MERGE_AUTOEDIT=no + +### gitfuzzy +export GF_BAT_STYLE=changes +export GF_BAT_THEME=zenbur +export GF_SNAPSHOT_DIRECTORY="$HOME/.local/git-fuzzy-snapshots" +if command -v delta > /dev/null; then + export GF_PREFERRED_PAGER="delta --theme=gruvbox --highlight-removed -w __WIDTH__" +fi + +### gping +# Replacement for ping that includes graph +if command -v gping > /dev/null; then + alias ping='gping' +fi + +### McFly +export MCFLY_FUZZY=2 +export MCFLY_RESULTS=14 +export MCFLY_KEY_SCHEME=vim + +### nnn +if command -v nnn > /dev/null; then + alias n='nnn -de' + alias N='sudo -E nnn -dH' + alias nnn-install-plugins='curl -Ls https://raw.githubusercontent.com/jarun/nnn/master/plugins/getplugs | sh' + export NNN_RCLONE='rclone mount --read-only --no-checksum' + export NNN_SSHFS='sshfs -o reconnect,idmap=user,cache_timeout=3600' +fi + +### Poetry +export POETRY_HOME="$HOME/.local/poetry" +export PATH="$POETRY_HOME/bin:$PATH" + +### Rear +# https://github.com/rear/rear/blob/master/doc/user-guide/03-configuration.adoc + +### ripgrep +export RIPGREP_CONFIG_PATH="$HOME/.config/ripgreprc" +if command -v rg &> /dev/null; then + alias grep='rg' +fi + +### Ruby +export GEM_HOME="$HOME/.local/gems" +export PATH="$PATH:$GEM_HOME/bin" + +### Volta +export VOLTA_HOME="$HOME/.local/volta" +export PATH="$VOLTA_HOME/bin:$PATH" +### SDKMan +export SDKMAN_DIR="$HOME/.local/sdkman" + +### Vagrant +export VAGRANT_DEFAULT_PROVIDER=virtualbox +export VAGRANT_HOME="$HOME/.local/vagrant.d" + +### wget +export WGETRC="$HOME/.config/wgetrc" diff --git a/dotfiles/.profile b/dotfiles/.profile index 431cab25..c15daccd 100644 --- a/dotfiles/.profile +++ b/dotfiles/.profile @@ -1,11 +1,14 @@ # shellcheck disable=SC1090,SC1091 -# Aliases / Functions -if [ -f "$HOME/.local/aliases" ]; then - . "$HOME/.local/aliases" +# Aliases / Functions / Exports +if [ -f "$XDG_CONFIG_HOME/shell/exports" ]; then + . "$XDG_CONFIG_HOME/shell/exports" fi -if [ -f "$HOME/.local/functions" ]; then - . "$HOME/.local/functions" +if [ -f "$XDG_CONFIG_HOME/shell/aliases" ]; then + . "$XDG_CONFIG_HOME/shell/aliases" +fi +if [ -f "$XDG_CONFIG_HOME/shell/functions" ]; then + . "$XDG_CONFIG_HOME/shell/functions" fi ### Bash / ZSH @@ -71,7 +74,7 @@ if [ "$BASH_SUPPORT" = 'true' ]; then ### ASDF if [ -f "$ASDF_DIR/asdf.sh" ]; then - . "$HOME/.local/asdf/asdf.sh" + . "$ASDF_DIR/asdf.sh" fi fi @@ -102,8 +105,8 @@ command -v bpytop > /dev/null && alias top='bpytop' command -v glances > /dev/null && alias top='glances' ### Cargo -if [ -f "$HOME/.cargo/env" ]; then - . "$HOME/.cargo/env" +if [ -f "$CARGO_HOME/env" ]; then + . "$CARGO_HOME/env" fi ### SDKMan