From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 4290 invoked from network); 26 Mar 1998 21:33:36 -0000 Received: from math.gatech.edu (list@130.207.146.50) by ns1.primenet.com.au with SMTP; 26 Mar 1998 21:33:36 -0000 Received: (from list@localhost) by math.gatech.edu (8.8.5/8.8.5) id QAA17798; Thu, 26 Mar 1998 16:29:47 -0500 (EST) Resent-Date: Thu, 26 Mar 1998 16:25:54 -0500 (EST) Message-ID: <19980326212511.17303@thelonious.new.ox.ac.uk> Date: Thu, 26 Mar 1998 21:25:11 +0000 From: Adam Spiers To: ZSH User Mailinglist Subject: Funky zsh prompts Reply-To: Adam Spiers Mail-Followup-To: ZSH User Mailinglist References: <199803251727.RAA05268@taos.demon.co.uk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.89.1i In-Reply-To: ; from C. v. Stuckrad on Thu, Mar 26, 1998 at 12:58:34PM +0100 Resent-Message-ID: <"C7OZi2.0.WK4.XVi6r"@math> Resent-From: zsh-users@math.gatech.edu X-Mailing-List: archive/latest/1432 X-Loop: zsh-users@math.gatech.edu X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu C. v. Stuckrad (stucki@math.fu-berlin.de) wrote: > On Wed, 25 Mar 1998, Andrew Main wrote: > > > >Benbar came up with the amusing idea of making the smiley prompt change > > >randomly every time I hit return (or even change to something that > > >reflects the load of the machine). > > > > Cool idea. Very cool! I think it's about time I posted my BPFH :-) Any suggestions for improving it welcome. -------- 8< -------- 8< -------- reset_colour="$(echo -n '\e[0m')" bold_colour="$(echo -n '\e[1m')" # Foreground grey="$(echo -n '\e[30m')" red="$(echo -n '\e[31m')" green="$(echo -n '\e[32m')" yellow="$(echo -n '\e[33m')" blue="$(echo -n '\e[34m')" magenta="$(echo -n '\e[35m')" cyan="$(echo -n '\e[36m')" white="$(echo -n '\e[37m')" # Background bg_grey="$(echo -n '\e[40m')" bg_red="$(echo -n '\e[41m')" bg_green="$(echo -n '\e[42m')" bg_yellow="$(echo -n '\e[43m')" bg_blue="$(echo -n '\e[44m')" bg_magenta="$(echo -n '\e[45m')" bg_cyan="$(echo -n '\e[46m')" bg_white="$(echo -n '\e[47m')" BASE_PROMPT="%{$bg_blue%}%m:%n%{$reset_colour%} " POST_PROMPT="%{$reset_colour%}" BASE_PROMPT_NO_COLOUR=$(echo "$BASE_PROMPT" | perl -pe "s/%{.*?%}//g") POST_PROMPT_NO_COLOUR=$(echo "$POST_PROMPT" | perl -pe "s/%{.*?%}//g") # Define prompts PROMPT_NEWLINE=$(echo -ne "\n%{\r%}") function precmd { setopt noxtrace localoptions local base_prompt base_prompt_etc prompt_length space_left base_prompt=$(print -P "$BASE_PROMPT_NO_COLOUR") base_prompt_etc=$(print -P "$base_prompt%(4~|...|)%3.") prompt_length=${#base_prompt_etc} # echo "Prompt length is $prompt_length" # echo "Base prompt length is $#base_prompt" if [[ $prompt_length -lt 40 ]]; then PATH_PROMPT="%{$bold_colour$cyan%}%(4~|...|)%3.%{$white%}" else space_left=$(( $COLUMNS - $#base_prompt - 2 )) # echo "Space left is $space_left" PATH_PROMPT="%{$bold_colour$green%}%${space_left}<...<%~$PROMPT_NEWLINE%{$white%}" fi PS1="$BASE_PROMPT$PATH_PROMPT %# $POST_PROMPT" PS2="$BASE_PROMPT$PATH_PROMPT %_> $POST_PROMPT" PS3="$BASE_PROMPT$PATH_PROMPT ?# $POST_PROMPT" }