From 95c99334dad0325a1ab3a206e6b06787b4be395f Mon Sep 17 00:00:00 2001 From: Joe Lillibridge Date: Tue, 29 Oct 2024 22:57:09 -0500 Subject: [PATCH] wip --- .config/starship.toml | 29 -------- .config/zsh/aliases | 24 +++++-- .config/zsh/environment##template | 33 +++++++++ .config/zsh/functions/fshow | 14 ++++ .config/zsh/functions/show-fpath | 7 ++ .config/zsh/functions/take | 6 ++ .config/zsh/functions/touchp | 5 ++ .config/zsh/functions/unbuff | 6 ++ .gitignore | 1 + .zshrc | 114 ++++++++++++++++++++---------- 10 files changed, 164 insertions(+), 75 deletions(-) delete mode 100644 .config/starship.toml create mode 100644 .config/zsh/environment##template create mode 100644 .config/zsh/functions/fshow create mode 100644 .config/zsh/functions/show-fpath create mode 100644 .config/zsh/functions/take create mode 100644 .config/zsh/functions/touchp create mode 100644 .config/zsh/functions/unbuff diff --git a/.config/starship.toml b/.config/starship.toml deleted file mode 100644 index a6a13a8..0000000 --- a/.config/starship.toml +++ /dev/null @@ -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 diff --git a/.config/zsh/aliases b/.config/zsh/aliases index 8d73862..c98d264 100644 --- a/.config/zsh/aliases +++ b/.config/zsh/aliases @@ -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 diff --git a/.config/zsh/environment##template b/.config/zsh/environment##template new file mode 100644 index 0000000..abc63fa --- /dev/null +++ b/.config/zsh/environment##template @@ -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 %} diff --git a/.config/zsh/functions/fshow b/.config/zsh/functions/fshow new file mode 100644 index 0000000..d509ac0 --- /dev/null +++ b/.config/zsh/functions/fshow @@ -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" +} diff --git a/.config/zsh/functions/show-fpath b/.config/zsh/functions/show-fpath new file mode 100644 index 0000000..e31eb39 --- /dev/null +++ b/.config/zsh/functions/show-fpath @@ -0,0 +1,7 @@ +# shellcheck disable=SC2148 +show-fpath() { + # shellcheck disable=SC2154 + for i in "${fpath[@]}"; do + echo "$i" + done +} \ No newline at end of file diff --git a/.config/zsh/functions/take b/.config/zsh/functions/take new file mode 100644 index 0000000..87d2aab --- /dev/null +++ b/.config/zsh/functions/take @@ -0,0 +1,6 @@ +# shellcheck disable=SC2148 +# Make a directory and cd into it +take() { + mkdir -p "$1"; + cd "$1" || exit; +} diff --git a/.config/zsh/functions/touchp b/.config/zsh/functions/touchp new file mode 100644 index 0000000..96c8052 --- /dev/null +++ b/.config/zsh/functions/touchp @@ -0,0 +1,5 @@ +# shellcheck disable=SC2148 +# Create an empty file and any necessary directories +touchp() { + mkdir -p "$(dirname "$1")" && touch "$1" +} \ No newline at end of file diff --git a/.config/zsh/functions/unbuff b/.config/zsh/functions/unbuff new file mode 100644 index 0000000..dc8ec73 --- /dev/null +++ b/.config/zsh/functions/unbuff @@ -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 +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index fd9d570..fca5741 100644 --- a/.gitignore +++ b/.gitignore @@ -58,6 +58,7 @@ Movies Music node_modules OneDrive\ \-\ Target\ Corporation +op-daemon.sock package.json Pictures Public diff --git a/.zshrc b/.zshrc index 0540ad5..ef5f9d6 100644 --- a/.zshrc +++ b/.zshrc @@ -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)"