lib: speed up slow parts of the lib files; other small fixes

This commit is contained in:
Marc Cornellà 2020-04-05 21:34:53 +02:00
parent dbd16000a5
commit 0caae9082a
4 changed files with 24 additions and 26 deletions

View File

@ -73,4 +73,4 @@ if [[ $COMPLETION_WAITING_DOTS = true ]]; then
fi
# automatically load bash completion functions
autoload -Uz bashcompinit && bashcompinit
autoload -U +X bashcompinit && bashcompinit

View File

@ -89,7 +89,7 @@ function default() {
# 0 if the env variable exists, 3 if it was set
#
function env_default() {
(( ${${(@f):-$(typeset +xg)}[(I)$1]} )) && return 0
[[ ${parameters[$1]} = *-export* ]] && return 0
export "$1=$2" && return 3
}

View File

@ -25,7 +25,7 @@ env_default 'LESS' '-R'
alias _='sudo '
## more intelligent acking for ubuntu users
if which ack-grep &> /dev/null; then
if (( $+commands[ack-grep] )); then
alias afind='ack-grep -il'
else
alias afind='ack -il'

View File

@ -1,4 +1,3 @@
#! /bin/zsh
# A script to make using 256 colors in zsh less painful.
# P.C. Shyamshankar <sykora@lucentbeing.com>
# Copied from https://github.com/sykora/etc/blob/master/zsh/functions/spectrum/
@ -19,19 +18,18 @@ for color in {000..255}; do
BG[$color]="%{[48;5;${color}m%}"
done
ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
# Show all 256 colors with color number
function spectrum_ls() {
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do
print -P -- "$code: %{$FG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
print -P -- "$code: $FG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done
}
# Show all 256 colors where the background is set to specific color
function spectrum_bls() {
local ZSH_SPECTRUM_TEXT=${ZSH_SPECTRUM_TEXT:-Arma virumque cano Troiae qui primus ab oris}
for code in {000..255}; do
print -P -- "$code: %{$BG[$code]%}$ZSH_SPECTRUM_TEXT%{$reset_color%}"
print -P -- "$code: $BG[$code]$ZSH_SPECTRUM_TEXT%{$reset_color%}"
done
}