-prompt_ds6_help() {
+prompt_arrows_help() {
cat << EOF
-prompt ds6 <right|2line> <normal> <prompt> <ssh> <urgent> <comment> <dir> <unwritable>
+prompt arrows <right|2line> <normal> <prompt> <ssh> <urgent> <comment> <dir> <unwritable>
The first parameter determines whether or not to use right-aligned status
text, or to put it above the command line.
EOF
}
-local prompt_ds6_vimode=
+local prompt_arrows_vimode=
-function prompt_ds6_setup() {
+function prompt_arrows_setup() {
# TODO: check for color terminal. never will use B&W term but still a XXX
local n p _p s r c d u
#TODO remove n?
local clock="%F{$n}%T%f" dirvcs="%F{$d}"'${vcs_info_msg_0_:-%~}'"%f"
local battery=/sys/class/power_supply/BAT0/capacity
[[ -e "$battery" ]] && clock+=" `cat $battery`%%"
- local vicol='%F{${${prompt_ds6_vimode:+'"$r"'}:-'"$c"'}}'
+ local vicol='%F{${${prompt_arrows_vimode:+'"$r"'}:-'"$c"'}}'
case "$m" {
2line)
PROMPT="%f $clock $dirvcs"$'\n'"%F{$c}>>> "
zstyle ':vcs_info:git*' stagedstr "%F{$c}+"
zstyle ':vcs_info:git*' unstagedstr "%F{$r}*"
- add-zsh-hook precmd prompt_ds6_precmd
- add-zsh-hook preexec prompt_ds6_preexec
+ add-zsh-hook precmd prompt_arrows_precmd
+ add-zsh-hook preexec prompt_arrows_preexec
zle -N zle-line-init
zle -A zle-line-init zle-keymap-select
}
# change color based on zle vi mode
function zle-line-init {
- prompt_ds6_vimode="${KEYMAP:/(main|viins)/}"
+ prompt_arrows_vimode="${KEYMAP:/(main|viins)/}"
zle reset-prompt
}
-function prompt_ds6_precmd {
+function prompt_arrows_precmd {
# TODO: check if vcs_info is autoloaded
vcs_info
}
-function prompt_ds6_preexec {
+function prompt_arrows_preexec {
print -Pn "%F{red}<<<%f "
}
-prompt_ds6_setup "$@"
+prompt_arrows_setup "$@"
# vim: set et fenc=utf-8 ft=zsh sts=4 sw=4 ts=8 tw=0 :
bindkey -a "^[[3~" delete-char
## history search
autoload -Uz up-line-or-beginning-search down-line-or-beginning-search && {
- if [[ -n "$key[Up]" ]] {
+ if [[ -n "$key[Up]" ]] {
zle -N up-line-or-beginning-search
bindkey -- "$key[Up]" up-line-or-beginning-search
}
}
## ps
local p=
-if which pstree >/dev/null 2>&1 && ! check-busybox pstree {
+if which pstree >/dev/null 2>&1 && ! check-busybox pstree; then
# use pstree, but NOT busybox pstree because it kinda sucks
p="pstree -wg3"
-} elif [[ "$OSTYPE" =~ '^freebsd' ]] {
+elif [[ "$OSTYPE" =~ '^freebsd' ]]; then
p="ps -aSdfxwwouser=USR -ogroup=GRP -opid,nice=NI \
-o%cpu,%mem,tty,stat,start=START -oetime,command"
-} elif check-busybox ps {
+elif check-busybox ps; then
# busybox compatible
p="ps -eouser='USR ' -ogroup='GRP ' \
-opid=' PID' -onice=' NI' -ovsz=' MEM' \
-otty,stat,etime,comm"
-} else {
+else
# XXX: untested, posix
# TODO: support gnu ps
p="ps -eouser=USR -ogroup=GRP -opid,nice=NI \
-opcpu=CPU -ovsz=MEM -otty,stat,etime,comm"
+fi
+if [[ "$(basename "$PAGER")" = "less" ]] {
+ p="$p | less -SE"
+} else {
+ p="$p | \"${PAGER:-more}\""
}
-p="$p | ${PAGER:-more} -Se"
alias pa="$p"
alias spa="sudo $p"
unset p
## prompt
# do this last so prompt can potentially override
autoload -Uz promptinit && promptinit
-prompt ds6
+prompt arrows
### unset imports