mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 02:06:39 +00:00
chore(zsh): various tweaks to zsh env setup and helpers
This commit is contained in:
@@ -17,7 +17,7 @@
|
||||
<key>EnvironmentVariables</key>
|
||||
<dict>
|
||||
<key>PATH</key>
|
||||
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin</string>
|
||||
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin</string>
|
||||
</dict>
|
||||
<key>StartCalendarInterval</key>
|
||||
<dict>
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
export POW_DST_PORT=88
|
||||
export HOME=~
|
||||
export PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:/usr/local/bin:$PATH"
|
||||
export PATH="$HOME/.rbenv/shims:$HOME/.rbenv/bin:/usr/local/bin:/opt/homebrew/bin:$PATH"
|
||||
|
||||
@@ -2,10 +2,6 @@
|
||||
# Google Cloud SDK setup.
|
||||
#
|
||||
|
||||
if [ -f '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc' ]; then
|
||||
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc'
|
||||
fi
|
||||
|
||||
# Lazy load gcloud shell completion on first use.
|
||||
if command-exists gcloud; then
|
||||
_python_argcomplete() {
|
||||
@@ -17,8 +13,8 @@ if command-exists gcloud; then
|
||||
|
||||
load-gcloud-completion() {
|
||||
unset -f load-gcloud-completion _python_argcomplete
|
||||
if [ -f '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc' ]; then
|
||||
source '/usr/local/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc'
|
||||
if [ -n "$HOMEBREW_PREFIX" ]; then
|
||||
source-if-exists "${HOMEBREW_PREFIX}/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/completion.zsh.inc"
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
@@ -23,11 +23,13 @@ if command-exists kubectl; then
|
||||
}
|
||||
_setup-kubectl-completion
|
||||
|
||||
if command-exists brew-prefix; then
|
||||
switch() {
|
||||
unset -f switch
|
||||
source "$(brew --prefix switch)/switch.sh"
|
||||
source "$(brew-prefix switch)/switch.sh"
|
||||
switch "$@"
|
||||
}
|
||||
fi
|
||||
|
||||
export KREW_ROOT="$HOME/.krew"
|
||||
path_append "${KREW_ROOT}/bin"
|
||||
|
||||
33
zshenv
33
zshenv
@@ -68,6 +68,12 @@ command-exists() {
|
||||
return $?
|
||||
}
|
||||
|
||||
source-if-exists() {
|
||||
if [ -f "$1" ]; then
|
||||
source "$1"
|
||||
fi
|
||||
}
|
||||
|
||||
# ==============================================================================
|
||||
# System Environment Setup
|
||||
# ==============================================================================
|
||||
@@ -126,6 +132,26 @@ if [ -f "/opt/homebrew/bin/brew" ]; then
|
||||
eval "$(/opt/homebrew/bin/brew shellenv)"
|
||||
fi
|
||||
|
||||
if command-exists brew; then
|
||||
typeset -A _brew_prefix_cache
|
||||
|
||||
brew-prefix() {
|
||||
local package="$1"
|
||||
|
||||
if [[ -z "$package" ]]; then
|
||||
package="__none__"
|
||||
fi
|
||||
|
||||
if [[ -n "${_brew_prefix_cache[$package]}" ]]; then
|
||||
echo "${_brew_prefix_cache[$package]}"
|
||||
else
|
||||
local result=$(brew --prefix "$package")
|
||||
_brew_prefix_cache[$package]=$result
|
||||
echo $result
|
||||
fi
|
||||
}
|
||||
fi
|
||||
|
||||
# Linuxbrew
|
||||
if [ -f "/home/linuxbrew/.linuxbrew/bin/brew" ]; then
|
||||
# Inline linux-brew setup to improve shell startup speed by around 200ms.
|
||||
@@ -209,11 +235,12 @@ path_prepend "$HOME/.local/share/rtx/bin"
|
||||
path_prepend "$HOME/.local/share/rtx/shims"
|
||||
|
||||
# orbstack setup
|
||||
if [ -f "$HOME/.orbstack/shell/init.zsh" ]; then
|
||||
source "$HOME/.orbstack/shell/init.zsh"
|
||||
fi
|
||||
source-if-exists "$HOME/.orbstack/shell/init.zsh"
|
||||
path_prepend "$HOME/.orbstack/bin"
|
||||
|
||||
# Google Cloud SDK setup
|
||||
source-if-exists "${HOMEBREW_PREFIX}/Caskroom/google-cloud-sdk/latest/google-cloud-sdk/path.zsh.inc"
|
||||
|
||||
# ==============================================================================
|
||||
# Path setup for select binaries installed with zinit
|
||||
# ==============================================================================
|
||||
|
||||
5
zshrc
5
zshrc
@@ -116,6 +116,11 @@ fi
|
||||
# Prompt
|
||||
# ==============================================================================
|
||||
|
||||
if ! command-exists starship; then
|
||||
read -q 'REPLY?starship is not installed, install with `rtx install starship`? [y/N]:' &&
|
||||
echo && rtx install starship
|
||||
fi
|
||||
|
||||
if command-exists starship; then
|
||||
eval "$(starship init zsh --print-full-init)"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user