Screen adaptive head(1) and tail(1) functions.
Bash:
function hed {
head -n $(( $(tput lines) - $(eval "wc -l <<<$'$PS1'") )) "$@"
}
function tal {
tail -n $(( $(tput lines) - $(eval "wc -l <<<$'$PS1'") )) "$@"
}
Zsh:
function hed {
head -n $(( $(tput lines) - $(wc -l <<<"$PS1") )) $@
}
function tal {
tail -n $(( $(tput lines) - $(wc -l <<<"$PS1") )) $@
}
Note that my Zsh PS1
has real newlines in it, so there is no need for eval
.