Skip to content

Instantly share code, notes, and snippets.

@hellekin
Created November 28, 2011 17:01
Show Gist options
  • Save hellekin/1401096 to your computer and use it in GitHub Desktop.
Save hellekin/1401096 to your computer and use it in GitHub Desktop.
Display an animated colored bar in zsh
#
# ZSH Raster -- Spice up your .zshrc
#
# {{{ Copyright 2011 Hellekin O. Wolf <hellekinλcepheide*org>
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# }}}
# {{{ Log ZSHRC Loading (and make it really sexy)
PLIP_PREFIX="%{%F{13}%B%}(%{%b%F{9}%}loading%{%B%F{7}%}:%{%F{13}%})%{%F{9}%} "
PLIP_SUFFIX="%{%b%f%}"
# \e[0K is clear to right (Thanks Val!)
print_line_in_place plip () { print -Pn "\r\e[0K${PLIP_PREFIX}${*}${PLIP_SUFFIX}" }
function zshrc_raster()
{
emulate -L zsh
setopt braceccl
local -F p=0.025
local s
local -i i
local -a c; c=( ▉ ▇ ▆ ▅ ▄ ▃ ▂ ▁ ▂ ▃ ▄ ▅ ▆ ▇ )
PLIP_PREFIX=''; PLIP_SUFFIX=''
for n in {1..78}
do
i+=1
plip "%{%B%F{$i}%}"$(printf "${c[$i]}%.0s" {1..${n}})"%{%f%b%}"
[[ $i == ${#c} ]] && i=0
sleep $p
done
}
zshrc_raster
#echo "\e[2J\e[0;0H"
# }}}
## Put more stuff and log each part using:
#
# plip "That part is loaded."
#
## So that when something breaks, you know where it is.
## Thanks to Val <val#v41*org> for inspiration.
# {{{ Finish Loading ZSHRC
## One last subliminal line and clear display.
plip "%F{7}ZSH Loaded. %F{13}Welcome, $USER\!\e[;f\e[2J"
# }}}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment