mirror of
https://github.com/jimeh/dotfiles.git
synced 2026-02-19 13:46:41 +00:00
chore(shell): add custom command-path helper
This commit is contained in:
@@ -32,5 +32,5 @@ fi
|
|||||||
|
|
||||||
if command-exists orb; then
|
if command-exists orb; then
|
||||||
alias oc="orb"
|
alias oc="orb"
|
||||||
setup-completions orb "$(command -v orb)" orb completion zsh
|
setup-completions orb "$(command-path orb)" orb completion zsh
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ git-largest-objects() {
|
|||||||
sed -n 's/^blob //p' |
|
sed -n 's/^blob //p' |
|
||||||
sort --numeric-sort --key=2 |
|
sort --numeric-sort --key=2 |
|
||||||
cut -c 1-12,41- |
|
cut -c 1-12,41- |
|
||||||
$(command -v gnumfmt || echo numfmt) \
|
$(command-path gnumfmt || echo numfmt) \
|
||||||
--field=2 \
|
--field=2 \
|
||||||
--to=iec-i \
|
--to=iec-i \
|
||||||
--suffix=B \
|
--suffix=B \
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ alias hl="helm"
|
|||||||
alias mk="minikube"
|
alias mk="minikube"
|
||||||
|
|
||||||
if command-exists kubectl; then
|
if command-exists kubectl; then
|
||||||
setup-completions kubectl "$(command -v kubectl)" kubectl completion zsh
|
setup-completions kubectl "$(command-path kubectl)" kubectl completion zsh
|
||||||
|
|
||||||
export KREW_ROOT="$HOME/.krew"
|
export KREW_ROOT="$HOME/.krew"
|
||||||
path_append "${KREW_ROOT}/bin"
|
path_append "${KREW_ROOT}/bin"
|
||||||
|
|||||||
@@ -22,10 +22,10 @@ fi
|
|||||||
# ==============================================================================
|
# ==============================================================================
|
||||||
|
|
||||||
if command-exists rustup; then
|
if command-exists rustup; then
|
||||||
setup-completions rustup "$(command -v rustup)" rustup completions zsh
|
setup-completions rustup "$(command-path rustup)" rustup completions zsh
|
||||||
|
|
||||||
if command-exists cargo; then
|
if command-exists cargo; then
|
||||||
setup-completions cargo "$(command -v cargo)" rustup completions zsh cargo
|
setup-completions cargo "$(command-path cargo)" rustup completions zsh cargo
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
if command-exists zoxide; then
|
if command-exists zoxide; then
|
||||||
cached-eval "$(command -v zoxide)" zoxide init --cmd zox zsh
|
cached-eval "$(command-path zoxide)" zoxide init --cmd zox zsh
|
||||||
|
|
||||||
# Use functions to allow regular zsh completion for cd to work.
|
# Use functions to allow regular zsh completion for cd to work.
|
||||||
cd() { __zoxide_z "$@"; }
|
cd() { __zoxide_z "$@"; }
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ setup-completions() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z "$(command -v "$cmd")" ]]; then
|
if [[ -z "$(command-path "$cmd")" ]]; then
|
||||||
echo "setup-completions: Command not found: $cmd" >&2
|
echo "setup-completions: Command not found: $cmd" >&2
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|||||||
6
zshenv
6
zshenv
@@ -68,6 +68,10 @@ command-exists() {
|
|||||||
return $?
|
return $?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
command-path() {
|
||||||
|
echo "${commands[$1]}"
|
||||||
|
}
|
||||||
|
|
||||||
source-if-exists() {
|
source-if-exists() {
|
||||||
if [ -f "$1" ]; then
|
if [ -f "$1" ]; then
|
||||||
source "$1"
|
source "$1"
|
||||||
@@ -107,7 +111,7 @@ cached-eval() {
|
|||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
local md5_cmd="$(command -v md5 || command -v md5sum)"
|
local md5_cmd="$(command-path md5 || command-path md5sum)"
|
||||||
local cache_hash="$(echo -n "${source_file}:${script}" | "$md5_cmd" | awk '{print $1}')"
|
local cache_hash="$(echo -n "${source_file}:${script}" | "$md5_cmd" | awk '{print $1}')"
|
||||||
local cache_file="${cache_dir}/${cache_hash}.cache.zsh"
|
local cache_file="${cache_dir}/${cache_hash}.cache.zsh"
|
||||||
|
|
||||||
|
|||||||
8
zshrc
8
zshrc
@@ -148,7 +148,7 @@ if command-exists fzf; then
|
|||||||
export FZF_TMUX_OPTS="-p 75%"
|
export FZF_TMUX_OPTS="-p 75%"
|
||||||
export FZF_TMUX_HEIGHT=""
|
export FZF_TMUX_HEIGHT=""
|
||||||
|
|
||||||
cached-eval "$(command -v fzf)" fzf --zsh
|
cached-eval "$(command-path fzf)" fzf --zsh
|
||||||
|
|
||||||
zstyle ':completion:*' menu no
|
zstyle ':completion:*' menu no
|
||||||
zstyle ':completion:*' special-dirs true
|
zstyle ':completion:*' special-dirs true
|
||||||
@@ -224,7 +224,7 @@ fi
|
|||||||
|
|
||||||
# If available, make sure to load direnv shell hook before mise.
|
# If available, make sure to load direnv shell hook before mise.
|
||||||
if command-exists direnv; then
|
if command-exists direnv; then
|
||||||
cached-eval "$(command -v direnv)" direnv hook zsh
|
cached-eval "$(command-path direnv)" direnv hook zsh
|
||||||
fi
|
fi
|
||||||
|
|
||||||
MISE_HOME="$HOME/.local/share/mise"
|
MISE_HOME="$HOME/.local/share/mise"
|
||||||
@@ -253,8 +253,8 @@ if ! command-exists starship && [ -f "$MISE_INSTALL_PATH" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if command-exists starship; then
|
if command-exists starship; then
|
||||||
setup-completions starship "$(command -v starship)" starship completions zsh
|
setup-completions starship "$(command-path starship)" starship completions zsh
|
||||||
cached-eval "$(command -v starship)" starship init zsh --print-full-init
|
cached-eval "$(command-path starship)" starship init zsh --print-full-init
|
||||||
else
|
else
|
||||||
echo "WARN: starship not found, skipping prompt setup" >&2
|
echo "WARN: starship not found, skipping prompt setup" >&2
|
||||||
echo " install with: mise install starship" >&2
|
echo " install with: mise install starship" >&2
|
||||||
|
|||||||
Reference in New Issue
Block a user