diff --git a/zsh/aliases.zsh b/zsh/aliases.zsh index 1a40d6f..99883bd 100644 --- a/zsh/aliases.zsh +++ b/zsh/aliases.zsh @@ -114,3 +114,11 @@ fi alias bytefmt2="numfmt --to=iec-i --suffix=B" alias bytefmt10="numfmt --to=si --suffix=B" + +if command_exists dragon-drag-and-drop && ! command_exists dragon; then + alias dragon='dragon-drag-and-drop' +fi + +if gnu_time_path="$(command_locate time)" && [[ -n "$gnu_time_path" ]]; then + alias gtime="${(q)gnu_time_path} -v" +fi diff --git a/zsh/functions.zsh b/zsh/functions.zsh index f378e7e..3a21626 100644 --- a/zsh/functions.zsh +++ b/zsh/functions.zsh @@ -26,7 +26,11 @@ viscd() { } } -command_exists() { command -v "$1" &>/dev/null; } +# Checks if a word can be meaningfully executed as a command (aliases, +# functions and builtins also count). +command_exists() { whence -- "$@" &>/dev/null; } +# Searches the command binary in PATH. +command_locate() { whence -p -- "$@"; } lazy_load() { local command="$1" @@ -131,3 +135,14 @@ sync_working_dir_load() { fi } alias cds="sync_working_dir_load" + +discord-avatar() { + setopt local_options err_return + if (( $# != 1 )); then + print >&2 "Usage: $0 [user_snowflake]" + return 1 + fi + local avatar_url + avatar_url="$(discord-whois --image-size 4096 --get 'Avatar' "$1")" + open "$avatar_url" +} diff --git a/zsh/plugins.zsh b/zsh/plugins.zsh index 1472428..174551f 100644 --- a/zsh/plugins.zsh +++ b/zsh/plugins.zsh @@ -14,8 +14,7 @@ _plugin completions-rustc 'https://raw.githubusercontent.com/rust-lang/zsh-confi _plugin completions-cargo 'https://raw.githubusercontent.com/rust-lang/cargo/master/src/etc/_cargo' from=url \ after_load='plugin-cfg-path fpath prepend ""' -rustup_bin="${commands[rustup]}" -if [[ -n "$rustup_bin" ]]; then +if rustup_bin="$(command_locate rustup)" && [[ -n "$rustup_bin" ]]; then rustup_comp_path="${ZSH_CACHE_DIR}/site-functions/_rustup" if [[ "$rustup_bin" -nt "$rustup_comp_path" || ! -s "$rustup_comp_path" ]]; then _perf_timer_start "generate rustup completions" @@ -23,7 +22,7 @@ if [[ -n "$rustup_bin" ]]; then _perf_timer_stop "generate rustup completions" fi unset rustup_comp_path -fi +fi; unset rustup_bin # compinit {{{ _perf_timer_start "compinit" @@ -146,4 +145,10 @@ if [[ "$TERM" != "linux" ]]; then fi fi +if (( _is_macos )); then + plugin retina 'https://raw.githubusercontent.com/lunixbochs/meta/master/utils/retina/retina.m' from=url \ + build='mkdir -p bin && gcc retina.m -framework Foundation -framework AppKit -o bin/retina' \ + after_load='plugin-cfg-path path prepend "bin"' +fi + unset _checkout_latest_version