enable almostontop plugin

almostontop plugin description https://github.com/Valiev/almostontop/blob/master/README.md
This commit is contained in:
Sergey Valiev 2016-02-24 20:54:34 +03:00
parent bd6dbd1d9b
commit bb88f9e436
2 changed files with 72 additions and 0 deletions

View File

@ -0,0 +1,13 @@
# almostontop
## Description
almostontop zsh plugin. It clears previous command output every time before new command
executed in shell. Insipred by [`alwaysontop`](https://github.com/swirepe/alwaysontop) plugin for bash
## Usage
source `almostontop.plugin.zsh` file and enjoy!
[![asciicast](https://asciinema.org/a/8rkdwvnp7atjseesp7n74nsyr.png)](https://asciinema.org/a/8rkdwvnp7atjseesp7n74nsyr)
## Author
[Sergey Valiev](https://github.com/Valiev)

View File

@ -0,0 +1,59 @@
if [ "x$ALMOSONTOP" = "xfalse" ]; then
# doing nothing here
else
ALMOSONTOP=true
fi
function almostontop_preexec
{
if [ "x$ALMOSONTOP" = "xtrue" ]; then
clear
# print PROMPT and command itself on the top
echo "$(print -P $prompt)$fg[green]${(z)1}$reset_color"
fi
}
autoload -U add-zsh-hook
add-zsh-hook preexec almostontop_preexec
function almostontop
{
# Help message if there no args
if [ $# -eq 0 ]; then
almostontop_usage
fi
local arg=$1
if [ "x$arg" = "xon" ]; then
ALMOSONTOP=true
fi
if [ "x$arg" = "xoff" ]; then
ALMOSONTOP=false
fi
if [ "x$arg" = "xtoggle" ]; then
if [ "x$ALMOSONTOP" = "xtrue" ]; then
almostontop off
else
almostontop on
fi
fi
}
function almostontop_usage
{
cat <<-EOF
Usage: almostontop <command>
Commands:
on Enables almostontop plugin
off Disables almostontop plugin
toggle Toggles almostontop plugin
Description:
almostontop clears previous command output every time before new command
executed in shell. Insipred by 'alwaysontop' plugin for bash:
https://github.com/swirepe/alwaysontop
EOF
}