From 578d0b5f8ba9b43d282a82a52fda198f6e45c885 Mon Sep 17 00:00:00 2001 From: Ade Attwood Date: Mon, 28 Dec 2020 09:19:32 +0000 Subject: [PATCH] pref(zsh): improve start up time of zsh Remove unused plugins and override composer plugin there was only one bit that was really slow when evaluating the bin directory --- .../core/files/oh-my-zsh/custom/composer.zsh | 52 +++++++++++++++++++ site-modules/core/files/zshrc | 6 +-- 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 site-modules/core/files/oh-my-zsh/custom/composer.zsh diff --git a/site-modules/core/files/oh-my-zsh/custom/composer.zsh b/site-modules/core/files/oh-my-zsh/custom/composer.zsh new file mode 100644 index 0000000..4f2d757 --- /dev/null +++ b/site-modules/core/files/oh-my-zsh/custom/composer.zsh @@ -0,0 +1,52 @@ +# ------------------------------------------------------------------------------ +# FILE: composer.plugin.zsh +# DESCRIPTION: oh-my-zsh composer plugin file. +# AUTHOR: Daniel Gomes (me@danielcsgomes.com) +# VERSION: 1.0.0 +# ------------------------------------------------------------------------------ + +# Composer basic command completion +_composer_get_command_list () { + $_comp_command1 --no-ansi 2>/dev/null | sed "1,/Available commands/d" | awk '/^[ \t]*[a-z]+/ { print $1 }' +} + +_composer_get_required_list () { + $_comp_command1 show -s --no-ansi 2>/dev/null | sed '1,/requires/d' | awk 'NF > 0 && !/^requires \(dev\)/{ print $1 }' +} + +_composer () { + local curcontext="$curcontext" state line + typeset -A opt_args + _arguments \ + '1: :->command'\ + '*: :->args' + + case $state in + command) + compadd $(_composer_get_command_list) + ;; + *) + compadd $(_composer_get_required_list) + ;; + esac +} + +compdef _composer composer +compdef _composer composer.phar + +# Aliases +alias c='composer' +alias csu='composer self-update' +alias cu='composer update' +alias cr='composer require' +alias crm='composer remove' +alias ci='composer install' +alias ccp='composer create-project' +alias cdu='composer dump-autoload' +alias cdo='composer dump-autoload --optimize-autoloader' +alias cgu='composer global update' +alias cgr='composer global require' +alias cgrm='composer global remove' + +# install composer in the current directory +alias cget='curl -s https://getcomposer.org/installer | php' diff --git a/site-modules/core/files/zshrc b/site-modules/core/files/zshrc index 58ed442..f49455f 100644 --- a/site-modules/core/files/zshrc +++ b/site-modules/core/files/zshrc @@ -27,7 +27,7 @@ COMPLETION_WAITING_DOTS="true" # More plug-ins are loaded in ~/.oh-my-zsh/custom/lib/misc.zsh file so we dint # have to define all of the custom installed plug ins here. # -plugins=(git golang composer npm tmux debian vagrant docker-compose extract emacs nvm) +plugins=(git emacs nvim extract) # # map ecs to caps lock @@ -43,7 +43,6 @@ xmodmap -e 'clear Lock' -e 'keycode 0x42 = Escape' # printf '\033[5 q' - # # Configure base16 shell for colors if the terminal is not running inside of # emacs @@ -108,9 +107,6 @@ if [ -d "${PHPENV_ROOT}" ]; then eval "$(phpenv init -)" fi -# conventional-tools autocomplete setup -CONVENTIONAL_TOOLS_AC_ZSH_SETUP_PATH=/home/ade/.cache/@baln/conventional-tools/autocomplete/zsh_setup && test -f $CONVENTIONAL_TOOLS_AC_ZSH_SETUP_PATH && source $CONVENTIONAL_TOOLS_AC_ZSH_SETUP_PATH; - export ANDROID_HOME=$HOME/Android/Sdk export PATH=$PATH:$ANDROID_HOME/emulator export PATH=$PATH:$ANDROID_HOME/tools