This commit is contained in:
Joe Lillibridge 2024-10-29 22:57:09 -05:00
parent f41f10cccd
commit 95c99334da
No known key found for this signature in database
10 changed files with 164 additions and 75 deletions

View File

@ -1,29 +0,0 @@
# Get editor completions based on the config schema
"$schema" = 'https://starship.rs/config-schema.json'
format = "$all$character"
# Inserts a blank line between shell prompts
add_newline = true
# Replace the '' symbol in the prompt with '➜'
# [character] # The name of the module we are configuring is 'character'
# success_symbol = '[➜](bold green)' # The 'success_symbol' segment is being set to '➜' with the color 'bold green'
[sudo]
style = 'bold green'
symbol = '👩‍💻 '
disabled = false
[status]
style = 'bg:blue'
symbol = '🔴 '
success_symbol = '🟢 SUCCESS'
format = '[\[$symbol$common_meaning$signal_name$maybe_int\]]($style) '
map_symbol = true
disabled = true
[custom.iterm_prompt_mark]
when = ''' ( it2check ) '''
format = "\u001b\\]133;A\u0007"
disabled = false

View File

@ -1,16 +1,22 @@
system_type=$(uname -s)
# aliases
alias more=less
alias mroe=less
alias mroe=more
alias tk=take
alias top10="print -l -- \${(o)history%% *} | uniq -c | sort -nr | head -n 10"
alias zsh-plugins="ls \$ZPLUGINDIR"
alias vi=nvim
# git aliases
alias g=git
alias gi=git
alias gg='git grep'
alias gs='git status'
alias gd='git diff'
alias gi=g
alias gg='g grep'
alias gs='g status'
alias gd='g diff'
alias ga='g add'
alias gap='ga -p'
alias gc='g commit'
# YADM aliases
alias y="yadm"
@ -18,13 +24,18 @@ alias ys="y status"
alias ysu="ys -u"
alias yg='y grep'
alias yd='y diff'
alias ya='y add'
alias yap='ya -p'
alias yc='y commit'
# Homebrew aliases
alias b="brew"
alias bi="b info"
alias bin="b install"
alias bu="b uninstall"
alias brm="bu"
alias bs="b search"
alias bv="brew-visit" # points to the function below because I'm complicated
alias bv="brew-visit" # a function defined elsewhere
# These depend on some installed packages, so just to be safe
alias ls="ls -F"
@ -40,7 +51,6 @@ alias hidehidden='defaults write com.apple.finder AppleShowAllFiles FALSE; killa
# For passing github token to gh
alias gh="op plugin run -- gh"
system_type=$(uname -s)
if [ "$system_type" = "Darwin" ]; then
# Open iTerm from VS Code terminal
# May refactor this to make the alias available in all non-iTerm terminals

View File

@ -0,0 +1,33 @@
system_type=$(uname -s)
# shellcheck disable=SC2148
# environment variables
export COLUMNS
export GREP_OPTIONS='--color=auto'
export PATH=$HOME/.local/bin:$PATH
export ZDOTDIR=${ZDOTDIR:-$HOME/.config/zsh}
export ZPLUGINDIR=${ZPLUGINDIR:-${ZDOTDIR}/plugins}
export NVM_DIR=$HOME/.nvm
{% if yadm.os == "Darwin" %}
export CLICOLOR=1
export HOMEBREW_BUNDLE_DUMP_NO_VSCODE=1
{% if yadm.class == "Work" %}
export NODE_EXTRA_CA_CERTS=$HOME/.config/target-certs/tgt-ca-bundle.crt
export VAULT_ADDR=https://prod.vault.target.com:443
export NODE_OPTIONS="--max_old_space_size=12288"
# I don't think this is needed; leaving it commented for now
# export GH_HOST=git.target.com
# 1Password secret references
# See:
# - https://developer.1password.com/docs/cli/secret-reference-syntax/
# - https://developer.1password.com/docs/cli/secrets-environment-variables/
export VPN_USERNAME="op://Target/Target Credentials/username"
export VPN_PASSWORD="op://Target/Target Credentials/password"
{% endif %}
{% endif %}

View File

@ -0,0 +1,14 @@
function fshow() {
git log --graph --color=always --format="%C(auto)%h%d %s %C(black)%C(bold)%cr" "$@" \
| fzf --ansi --preview "echo {} \
| grep -o '[a-f0-9]\{7\}' \
| head -1 \
| xargs -I % sh -c 'git show --color=always %'" \
--bind "enter:execute:
(grep -o '[a-f0-9]\{7\}' \
| head -1 \
| xargs -I % sh -c 'git show --color=always % \
| less -R') << 'FZF-EOF'
{}
FZF-EOF"
}

View File

@ -0,0 +1,7 @@
# shellcheck disable=SC2148
show-fpath() {
# shellcheck disable=SC2154
for i in "${fpath[@]}"; do
echo "$i"
done
}

View File

@ -0,0 +1,6 @@
# shellcheck disable=SC2148
# Make a directory and cd into it
take() {
mkdir -p "$1";
cd "$1" || exit;
}

View File

@ -0,0 +1,5 @@
# shellcheck disable=SC2148
# Create an empty file and any necessary directories
touchp() {
mkdir -p "$(dirname "$1")" && touch "$1"
}

View File

@ -0,0 +1,6 @@
# Preserve color when handed around via STD IO
# example usage:
# $ unbuff ls --color=auto -F | tee output.txt
unbuff() {
script -q >(cat) $* >/dev/null
}

1
.gitignore vendored
View File

@ -58,6 +58,7 @@ Movies
Music
node_modules
OneDrive\ \-\ Target\ Corporation
op-daemon.sock
package.json
Pictures
Public

114
.zshrc
View File

@ -1,37 +1,54 @@
system_type=$(uname -s)
# shell options
setopt auto_cd append_history share_history histignorealldups
# Shell options
OPTIONS=(
auto_cd
append_history
share_history
histignorealldups
# aliases
get_ls_command() {
command -v lsd &>/dev/null
if [ $? -eq 0 ]; then
echo "lsd"
## Gonna slowly turn these on and see what I like
# auto_list
# auto_menu
# auto_pushd
# completeinword
# correct
# extended_history
# histexpiredupsfirst
# histignoredups
# histignorespace
# histverify # this one can get annoying...
# interactivecomments
# listpacked
# longlistjobs
# nocaseglob
# noflowcontrol
# promptsubst
# pushdignoredups
# pushdminus
)
setopt $OPTIONS[@]
fpath+=($HOME/.config/zsh/functions)
FILES_TO_SOURCE=(
$HOME/.config/zsh/aliases
$HOME/.config/zsh/environmental
$HOME/.zsh-unplugged # extremely minimal "package manager"
$HOME/.iterm2_shell_integration.zsh
$HOMEBREW_PREFIX/opt/nvm/nvm.sh
$HOMEBREW_PREFIX/opt/nvm/etc/bash_completion.d/nvm
)
for file in "${FILES_TO_SOURCE[@]}"; do
if [ -s $file ]; then
source "$file"
else
echo "ls"
echo "WARNING: $file is empty or does not exist."
fi
}
alias ls="$(get_ls_command) -F"
# git aliases
alias g=git
alias gi=git
# Homebrew aliases
alias b="brew"
alias bv="brew-visit" # points to the function below because I'm complicated
alias bi="brew info"
alias bs="brew search"
# YADM aliases
alias y="yadm"
alias ys="y status"
alias ysu="ys -u"
# These depend on some installed packages, so just to be safe
[[ "$(command -v bat)" ]] && alias cat="bat"
[[ "$(command -v htop)" ]] && alias top="htop"
done
# environment variables
export PATH="$PATH:${HOME}/.local/bin"
@ -39,18 +56,38 @@ export CLICOLOR=1
# export ZSH_HIGHLIGHT_HIGHLIGHTERS_DIR=/opt/homebrew/share/zsh-syntax-highlighting/highlighters
# Load functions
fpath+=( "$HOME/.config/zsh/functions" )
autoload -Uz ql f brew-visit tre compinit && compinit
fpath+=("$HOME/.config/zsh/functions")
FUNCS_TO_AUTOLOAD=(
brew-visit
f
fshow
ql
show-fpath
take
tre
touchp
unbuff
promptinit
compinit
)
autoload -Uz $FUNCS_TO_AUTOLOAD && compinit && promptinit
prompt pure
[ -f ~/.fzf.zsh ] && source ~/.fzf.zsh && source <(fzf --zsh)
[ -f ~/.config/op/plugins.sh ] && source ~/.config/op/plugins.sh
[ -f /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[ -f /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh ] && source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
[ -f /opt/homebrew/opt/git-extras/share/git-extras/git-extras-completion.zsh ] && source /opt/homebrew/opt/git-extras/share/git-extras/git-extras-completion.zsh
[ -f /opt/homebrew/share/liquidprompt ] && source /opt/homebrew/share/liquidprompt
[ -e "${HOME}/.iterm2_shell_integration.zsh" ] && source "${HOME}/.iterm2_shell_integration.zsh"
if it2check; then
if [ "$system_type" = "Darwin" ]; then
[ -f ~/.config/op/plugins.sh ] && source ~/.config/op/plugins.sh
[ -e "${HOME}/.iterm2_shell_integration.zsh" ] && source "${HOME}/.iterm2_shell_integration.zsh"
[ -f /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh ] && source /opt/homebrew/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
[ -f /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh ] && source /opt/homebrew/share/zsh-autosuggestions/zsh-autosuggestions.zsh
[ -f /opt/homebrew/opt/git-extras/share/git-extras/git-extras-completion.zsh ] && source /opt/homebrew/opt/git-extras/share/git-extras/git-extras-completion.zsh
# [ -f /opt/homebrew/share/liquidprompt ] && source /opt/homebrew/share/liquidprompt
fi
$HOME/.iterm2/it2check
export TERMINAL_IS_ITERM2=$?
if [ $TERMINAL_IS_ITERM2 -eq 0 ]; then
iterm2_print_user_vars() {
it2git
}
@ -58,4 +95,3 @@ fi
eval "$(zoxide init --cmd j zsh)"
eval $(thefuck --alias)
# eval "$(starship init zsh)"