From 4f4710136460159118320a2c2a5e1515746e52ac Mon Sep 17 00:00:00 2001 From: sev Date: Wed, 18 Mar 2020 23:22:23 -0500 Subject: [PATCH] fix .zshrc, pa, spa; rename prompt to arrows --- .../{prompt_ds6_setup => prompt_arrows_setup} | 22 +++++++++---------- base/.zshrc | 18 +++++++++------ 2 files changed, 22 insertions(+), 18 deletions(-) rename base/.zsh/{prompt_ds6_setup => prompt_arrows_setup} (84%) diff --git a/base/.zsh/prompt_ds6_setup b/base/.zsh/prompt_arrows_setup similarity index 84% rename from base/.zsh/prompt_ds6_setup rename to base/.zsh/prompt_arrows_setup index b1f5613..517c262 100644 --- a/base/.zsh/prompt_ds6_setup +++ b/base/.zsh/prompt_arrows_setup @@ -1,6 +1,6 @@ -prompt_ds6_help() { +prompt_arrows_help() { cat << EOF -prompt ds6 +prompt arrows The first parameter determines whether or not to use right-aligned status text, or to put it above the command line. @@ -18,9 +18,9 @@ respectively. 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? @@ -47,7 +47,7 @@ function prompt_ds6_setup() { 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}>>> " @@ -69,26 +69,26 @@ function prompt_ds6_setup() { 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 : diff --git a/base/.zshrc b/base/.zshrc index eec9016..96f14c5 100644 --- a/base/.zshrc +++ b/base/.zshrc @@ -34,7 +34,7 @@ bindkey "^[[3~" delete-char #Del 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 } @@ -56,24 +56,28 @@ if [[ "$OSTYPE" =~ '^(free|net)bsd' ]] { } ## 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 @@ -205,7 +209,7 @@ compinit ## prompt # do this last so prompt can potentially override autoload -Uz promptinit && promptinit -prompt ds6 +prompt arrows ### unset imports -- 2.47.0