mirror of
https://github.com/ivuorinen/dotfiles.git
synced 2026-01-26 11:14:08 +00:00
feat: x-path-* as scripts, run other changes
This commit is contained in:
@@ -18,6 +18,12 @@ export XDG_BIN_HOME="$HOME/.local/bin"
|
||||
export XDG_CACHE_HOME="$HOME/.cache"
|
||||
export XDG_RUNTIME_DIR="$HOME/.local/run"
|
||||
|
||||
source "$DOTFILES/config/exports"
|
||||
|
||||
# shellcheck source=../config/fzf/fzf.bash
|
||||
[ -f "${DOTFILES}/config/fzf/fzf.bash" ] &&
|
||||
source "${DOTFILES}/config/fzf/fzf.bash"
|
||||
|
||||
# Import ssh keys in keychain
|
||||
ssh-add -A 2>/dev/null
|
||||
|
||||
@@ -96,5 +102,3 @@ export OSH="$HOME/.local/share/oh-my-bash"
|
||||
# export EDITOR='mvim'
|
||||
# fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -16,3 +16,4 @@ export XDG_BIN_HOME="$HOME/.local/bin"
|
||||
export XDG_CACHE_HOME="$HOME/.cache"
|
||||
export XDG_RUNTIME_DIR="$HOME/.local/run"
|
||||
|
||||
source "$DOTFILES/config/exports"
|
||||
|
||||
11
base/zshrc
11
base/zshrc
@@ -1,6 +1,12 @@
|
||||
# this is my zsh config. there are many like it, but this one is mine.
|
||||
# shellcheck shell=bash
|
||||
|
||||
export PATH="$HOME/.local/bin:$HOME/.dotfiles/local/bin:$HOME/.local/go/bin:$PATH"
|
||||
|
||||
source "$DOTFILES/config/exports"
|
||||
source "$DOTFILES/config/alias"
|
||||
source "$DOTFILES/config/functions"
|
||||
|
||||
source "$DOTFILES/scripts/shared.sh"
|
||||
|
||||
export COMPLETION_WAITING_DOTS=true
|
||||
@@ -17,11 +23,6 @@ path_prepend "$XDG_BIN_HOME"
|
||||
path_prepend "$HOME/.local/go/bin"
|
||||
path_prepend "$XDG_DATA_HOME/bob/nvim-bin"
|
||||
|
||||
source "$DOTFILES/config/exports-shell"
|
||||
source "$DOTFILES/config/exports-apps"
|
||||
source "$DOTFILES/config/alias"
|
||||
source "$DOTFILES/config/functions"
|
||||
|
||||
export ZSH_CUSTOM_COMPLETION_PATH="$XDG_CONFIG_HOME/zsh/completion"
|
||||
x-dc "$ZSH_CUSTOM_COMPLETION_PATH"
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ DOTFILES="$HOME/.dotfiles"
|
||||
# Get installed php versions from brew and setup aliases
|
||||
function x-set-php-aliases
|
||||
{
|
||||
have brew && {
|
||||
x-have brew && {
|
||||
local php_versions=()
|
||||
while IFS="" read -r line; do php_versions+=("$line"); done < <(brew_installed | grep '^php')
|
||||
while IFS="" read -r line; do php_versions+=("$line"); done < <(bkt -- brew list | grep '^php')
|
||||
|
||||
php_error_reporting='-d error_reporting=22527'
|
||||
|
||||
@@ -61,8 +61,8 @@ alias please="sudo "
|
||||
# Color the grep output
|
||||
alias grep='grep --color'
|
||||
|
||||
! have eza && alias ls='ls --color=auto'
|
||||
have eza && {
|
||||
! x-have eza && alias ls='ls --color=auto'
|
||||
x-have eza && {
|
||||
alias ls='eza -h -s=type --git --icons --group-directories-first'
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,57 @@
|
||||
# shellcheck shell=bash
|
||||
# vim: filetype=zsh
|
||||
|
||||
# Cache commands using bkt if installed
|
||||
if command -v bkt >&/dev/null; then
|
||||
bkt()
|
||||
{
|
||||
command bkt --cache-dir="$XDG_CACHE_HOME/bkt" "$@"
|
||||
}
|
||||
else
|
||||
# If bkt isn't installed skip its arguments and just execute directly.
|
||||
# Optionally write a msg to stderr suggesting users install bkt.
|
||||
bkt()
|
||||
{
|
||||
while [[ "$1" == --* ]]; do shift; done
|
||||
"$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# shorthand for checking if the system has the bin in path,
|
||||
# this version does not use caching
|
||||
# usage: have_command php && php -v
|
||||
function have_command
|
||||
{
|
||||
command -v "$1" >&/dev/null
|
||||
}
|
||||
|
||||
# shorthand for checking if the system has the bin in path,
|
||||
# this version uses caching
|
||||
# usage: have php && php -v
|
||||
function have
|
||||
{
|
||||
bkt -- which "$1" >&/dev/null
|
||||
}
|
||||
|
||||
function brew_installed
|
||||
{
|
||||
bkt -- brew list
|
||||
}
|
||||
|
||||
# shorthand for checking if brew package is installed
|
||||
# usage: have_brew php && php -v
|
||||
function have_brew
|
||||
{
|
||||
! have brew && return 125
|
||||
|
||||
if bkt -- brew list "$1" &> /dev/null; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
source "$DOTFILES/config/exports-shell"
|
||||
source "$DOTFILES/config/exports-apps"
|
||||
|
||||
have nvim && export EDITOR="nvim"
|
||||
x-have nvim && export EDITOR="nvim"
|
||||
|
||||
@@ -21,15 +21,15 @@ x-dc "$ANSIBLE_GALAXY_CACHE_DIR"
|
||||
export ANDROID_HOME="$XDG_DATA_HOME/android"
|
||||
|
||||
# bob manages nvim versions
|
||||
path_prepend "$XDG_DATA_HOME/bob/nvim-bin"
|
||||
have nvim && export EDITOR="nvim"
|
||||
x-path-prepend "$XDG_DATA_HOME/bob/nvim-bin"
|
||||
x-have nvim && export EDITOR="nvim"
|
||||
|
||||
export HOMEBREW_NO_ENV_HINTS=true
|
||||
|
||||
# composer, https://getcomposer.org/
|
||||
export COMPOSER_HOME="$XDG_STATE_HOME/composer"
|
||||
export COMPOSER_BIN="$COMPOSER_HOME/vendor/bin"
|
||||
path_append "$COMPOSER_BIN"
|
||||
x-path-append "$COMPOSER_BIN"
|
||||
|
||||
# docker, https://docs.docker.com/engine/reference/commandline/cli/
|
||||
export DOCKER_CONFIG="$XDG_CONFIG_HOME/docker"
|
||||
@@ -39,7 +39,7 @@ export DOCKER_SCAN_SUGGEST=false
|
||||
|
||||
# ffmpeg
|
||||
export FFMPEG_DATADIR="$XDG_CONFIG_HOME/ffmpeg"
|
||||
have ffmpeg && x-dc "$FFMPEG_DATADIR"
|
||||
x-have ffmpeg && x-dc "$FFMPEG_DATADIR"
|
||||
|
||||
# GnuPG
|
||||
export GNUPGHOME="$XDG_DATA_HOME/gnupg"
|
||||
@@ -53,14 +53,14 @@ export NBRC_PATH="$XDG_CONFIG_HOME/nbrc"
|
||||
export NB_DIR="$XDG_STATE_HOME/nb"
|
||||
|
||||
# NPM: Add npm packages to path
|
||||
have node && {
|
||||
x-have node && {
|
||||
NVM_NODE_BIN_DIR="$(dirname "$(which node)")"
|
||||
path_append "$NVM_NODE_BIN_DIR"
|
||||
x-path-append "$NVM_NODE_BIN_DIR"
|
||||
}
|
||||
|
||||
# op (1Password cli) is present
|
||||
export OP_CACHE="$XDG_STATE_HOME/1password"
|
||||
have op && {
|
||||
x-have op && {
|
||||
[ "$DOTFILES_CURRENT_SHELL" = "zsh" ] && {
|
||||
eval "$(op completion zsh)"
|
||||
compdef _op op
|
||||
@@ -72,8 +72,8 @@ have op && {
|
||||
# pyenv, python environments
|
||||
export WORKON_HOME="$XDG_DATA_HOME/virtualenvs"
|
||||
export PYENV_ROOT="$XDG_STATE_HOME/pyenv"
|
||||
have pyenv && {
|
||||
path_append "$PYENV_ROOT/shims"
|
||||
x-have pyenv && {
|
||||
x-path-append "$PYENV_ROOT/shims"
|
||||
eval "$(pyenv init -)"
|
||||
}
|
||||
|
||||
@@ -87,8 +87,8 @@ export BUNDLE_USER_CACHE="$XDG_CACHE_HOME"/bundle
|
||||
export BUNDLE_USER_PLUGIN="$XDG_DATA_HOME"/bundle
|
||||
export RBENV_ROOT="$XDG_STATE_HOME/rbenv"
|
||||
x-dc "$RBENV_ROOT"
|
||||
have gem && path_append "${GEM_HOME}/bin"
|
||||
have rbenv && {
|
||||
x-have gem && x-path-append "${GEM_HOME}/bin"
|
||||
x-have rbenv && {
|
||||
[ "$DOTFILES_CURRENT_SHELL" = "zsh" ] && eval "$(rbenv init - zsh)"
|
||||
[ "$DOTFILES_CURRENT_SHELL" = "bash" ] && eval "$(rbenv init - bash)"
|
||||
}
|
||||
@@ -96,7 +96,7 @@ have rbenv && {
|
||||
# Rust / cargo
|
||||
export RUSTUP_HOME="$XDG_DATA_HOME/rustup"
|
||||
export CARGO_HOME="$XDG_DATA_HOME/cargo"
|
||||
path_append "$CARGO_HOME/bin"
|
||||
x-path-append "$CARGO_HOME/bin"
|
||||
|
||||
# screen
|
||||
export SCREENRC="$XDG_CONFIG_HOME/misc/screenrc"
|
||||
|
||||
@@ -54,32 +54,3 @@ export GREP_OPTIONS="--color=auto"
|
||||
# update the values of LINES and COLUMNS.
|
||||
hash shopt 2> /dev/null && shopt -s checkwinsize
|
||||
|
||||
# Set dircolors based on the file, if it exists
|
||||
have dircolors && eval $(dircolors "$XDG_CONFIG_HOME/dircolors")
|
||||
|
||||
# If we are using zsh, color our dir lists and such
|
||||
if [ "$DOTFILES_CURRENT_SHELL" = "-zsh" ]; then
|
||||
[[ $ZSH_VERSION != "" ]] && {
|
||||
autoload -U colors zsh/terminfo compinit
|
||||
colors
|
||||
compinit -d "$XDG_CACHE_HOME"/zsh/zcompdump-"$ZSH_VERSION"
|
||||
|
||||
x-dc "$XDG_CACHE_HOME/zsh"
|
||||
x-dc "$XDG_STATE_HOME/zsh"
|
||||
export HISTFILE="$XDG_STATE_HOME/zsh/history"
|
||||
zstyle ':completion:*' cache-path "$XDG_CACHE_HOME/zsh/zcompcache"
|
||||
zstyle ':completion:*' list-colors "$LS_COLORS"
|
||||
|
||||
# Load iterm2 shell integration
|
||||
# https://iterm2.com/documentation-shell-integration.html
|
||||
[[ -f "$XDG_BIN_HOME/iterm2_shell_integration.zsh" ]] \
|
||||
&& source "$XDG_BIN_HOME/iterm2_shell_integration.zsh"
|
||||
}
|
||||
fi
|
||||
|
||||
# If we are using bash
|
||||
if [ "$DOTFILES_CURRENT_SHELL" = "bash" ]; then
|
||||
# shellcheck source=../config/fzf/fzf.bash
|
||||
[ -f "${DOTFILES}/config/fzf/fzf.bash" ] &&
|
||||
source "${DOTFILES}/config/fzf/fzf.bash"
|
||||
fi
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
which "$1" >&/dev/null
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo 0
|
||||
exit 0
|
||||
else
|
||||
echo 1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
8
local/bin/x-path-append
Executable file
8
local/bin/x-path-append
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Add a directory to the beginning of the PATH if it's not already there.
|
||||
# Usage: x-path-append <dir>
|
||||
|
||||
x-path-remove "$1"
|
||||
export PATH="${PATH:+"$PATH:"}$1"
|
||||
|
||||
7
local/bin/x-path-prepend
Executable file
7
local/bin/x-path-prepend
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Add a directory to the front of the PATH if it exists and is not already there
|
||||
# Usage: x-path-prepend <dir>
|
||||
|
||||
export PATH="$1${PATH:+":$PATH"}"
|
||||
|
||||
7
local/bin/x-path-remove
Executable file
7
local/bin/x-path-remove
Executable file
@@ -0,0 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# Remove a directory from the PATH
|
||||
# Usage: x-path-remove <dir>
|
||||
|
||||
export PATH=$(echo -n "$PATH" | awk -v RS=: -v ORS=: "\$0 != \"$1\"" | sed 's/:$//')
|
||||
|
||||
@@ -31,23 +31,23 @@ export XDG_RUNTIME_DIR="$HOME/.local/run"
|
||||
# usage: path_remove ~/.local/bin
|
||||
function path_remove
|
||||
{
|
||||
PATH=$(echo -n "$PATH" | awk -v RS=: -v ORS=: "\$0 != \"$1\"" | sed 's/:$//')
|
||||
x-path-remove "$1"
|
||||
}
|
||||
|
||||
# Append directory to the PATH
|
||||
# usage: path_append ~/.local/bin
|
||||
function path_append
|
||||
{
|
||||
path_remove "$1"
|
||||
PATH="${PATH:+"$PATH:"}$1"
|
||||
x-path-remove "$1"
|
||||
x-path-prepend "$1"
|
||||
}
|
||||
|
||||
# Prepend directory to the PATH
|
||||
# usage: path_prepend ~/.local/bin
|
||||
function path_prepend
|
||||
{
|
||||
path_remove "$1"
|
||||
PATH="$1${PATH:+":$PATH"}"
|
||||
x-path-remove "$1"
|
||||
x-path-prepend "$1"
|
||||
}
|
||||
|
||||
# Create directory if it doesn't exist already
|
||||
@@ -84,56 +84,6 @@ nonascii()
|
||||
LC_ALL=C grep -n '[^[:print:][:space:]]' "${@}"
|
||||
}
|
||||
|
||||
# Cache commands using bkt if installed
|
||||
if command -v bkt >&/dev/null; then
|
||||
bkt()
|
||||
{
|
||||
command bkt --cache-dir="$XDG_CACHE_HOME/bkt" "$@"
|
||||
}
|
||||
else
|
||||
# If bkt isn't installed skip its arguments and just execute directly.
|
||||
# Optionally write a msg to stderr suggesting users install bkt.
|
||||
bkt()
|
||||
{
|
||||
while [[ "$1" == --* ]]; do shift; done
|
||||
"$@"
|
||||
}
|
||||
fi
|
||||
|
||||
# shorthand for checking if the system has the bin in path,
|
||||
# this version does not use caching
|
||||
# usage: have_command php && php -v
|
||||
function have_command
|
||||
{
|
||||
command -v "$1" >&/dev/null
|
||||
}
|
||||
|
||||
# shorthand for checking if the system has the bin in path,
|
||||
# this version uses caching
|
||||
# usage: have php && php -v
|
||||
function have
|
||||
{
|
||||
bkt -- which "$1" >&/dev/null
|
||||
}
|
||||
|
||||
function brew_installed
|
||||
{
|
||||
bkt -- brew list
|
||||
}
|
||||
|
||||
# shorthand for checking if brew package is installed
|
||||
# usage: have_brew php && php -v
|
||||
function have_brew
|
||||
{
|
||||
! have brew && return 125
|
||||
|
||||
if bkt -- brew list "$1" &> /dev/null; then
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
CONFIG_PATH="$DOTFILES/config"
|
||||
|
||||
# Load the shell dotfiles, and then some:
|
||||
|
||||
Reference in New Issue
Block a user