1
0
Fork 0

Speed up shell start by pre-generating shell-banner-file

Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
Knut Ahlers 2018-06-25 10:27:41 +02:00
parent 6dbe0111c5
commit 31f49a8afd
Signed by: luzifer
GPG key ID: DC2729FDD34BE99E
3 changed files with 50 additions and 3 deletions

View file

@ -1,8 +1,11 @@
## If any print shell banner
[ -f ${HOME}/.local/shell-banner.txt ] && cat ${HOME}/.local/shell-banner.txt
## Brew installed binaries
export PATH=/usr/local/sbin:/usr/local/bin:$PATH
## Activate go using gimme if any go version is available
source ${HOME}/.zsh/check_go_version
[ -e ${HOME}/.gimme/envs/latest.env ] && source ${HOME}/.gimme/envs/latest.env
## Custom scripts
export PATH=$HOME/bin:$HOME/.bin:$PATH
@ -49,7 +52,6 @@ source ${HOME}/.zsh/gpg-agent.plugin.zsh
## Load config-git functions and check for config updates
source ${HOME}/.zsh/config-git.zsh
${HOME}/bin/check_config
## Load local-config if available
[ -e ${HOME}/.zsh/local-config.zsh ] && source ${HOME}/.zsh/local-config.zsh

View file

@ -22,7 +22,7 @@ function join_by() {
# Wrap git to work with git-dir and work-tree being in other locations
function gwrap() {
hub --git-dir=${HOME}/.cfg/${REPO} --work-tree=${HOME} $@
git --git-dir=${HOME}/.cfg/${REPO} --work-tree=${HOME} $@
}
# Ensure we're connected to network before acting
@ -58,4 +58,10 @@ done
if [ ${#NEED_UPDATE[@]} -gt 0 ]; then
echo "Config repo $(join_by ", " "${NEED_UPDATE[@]}") needs update"
else
if ( ${HOME}/bin/config-git-status.sh ); then
echo "Up-to-date"
else
echo "Up-to-date with uncommitted changes"
fi
fi

39
bin/gen-shell-banner.sh Executable file
View file

@ -0,0 +1,39 @@
#!/bin/bash
set -euo pipefail
function kv() {
printf "$(boxchar 78) %15s: %-64s $(boxchar 78)\n" "$@"
}
function boxchar() {
printf "\x1b(0\x$1\x1b(B"
}
## Redirect stdout into shell-banner.txt
exec >${HOME}/.local/shell-banner.txt
## Start output
printf "$(boxchar 6c)%083s$(boxchar 6b)\n" | sed "s/ /$(printf "$(boxchar 71)")/g"
## Check whether config repos needs update
kv "Config" "$(${HOME}/bin/check_config)"
## Check for latest Go version
if ( ping -c 1 -q 8.8.8.8 >/dev/null ); then
GO_VER=$(curl -sSLf -m 2 'https://lv.luzifer.io/catalog-api/golang/latest.txt?p=version')
if [ -e "${HOME}/.gimme/envs/go${GO_VER}.env" ]; then
kv "Go-Version" "Up-to-date (${GO_VER})"
else
kv "Go-Version" "Outdated (latest would be ${GO_VER})"
fi
else
kv "Go-Version" "Unknown, network unreachable"
fi
## Log generation time
kv "Updated" "$(date +"%Y-%m-%d %H:%M")"
## End output
printf "$(boxchar 6d)%083s$(boxchar 6a)\n" | sed "s/ /$(printf "$(boxchar 71)")/g"
echo # Add an extra blank line