Mine is ever so slightly more complicated than yours:
PROMPT=$’%(!.%F{red}.%F{blue})%D{%a %R} %B[%m:%35<..<%~%<<] %n%#%b%f '
RPROMPT=$'%(!.%F{red}.%F{blue})<%(1j. %BJ%j%b.)%f'
if (( $SHLVL != ${ZSHLVL:=$SHLVL} ))
then
RPROMPT=$RPROMPT$' %F{magenta}Z'$(( $SHLVL – $ZSHLVL ))$'%f'
fi
export ZSHLVL
My PS1 is different depending on the environment.
In normal terminal session it is: \h:\w \u\$
But within Emacs (where most of my shell work is) it is simply: [\t] \$
# This prompt has the hostname and up to two levels of directory context. Just one level often doesn’t disambiguate, and more than two is often annoying. So a session might go:
# [mymachine ~]$ cd foo
# [mymachine ~/foo]$ cd bar
# [mymachine foo/bar]$ cd baz
# [mymachine bar/baz]$
# The actual code:
echo ‘($H)=($ENV{HOST}=~/([^\.]+ /);s|$ENV{HOME}|~|g;s|.+/([^/]+/[^/]+)$| ${1}|g;s|^|$H |;’ > $HOME/._sp
# Running it:
function sp () { PS1=”[`pwd | perl -p $HOME/._sp`]\$ “; }
# Install it into the prompt:
# precmd is a special tcsh alias executed before every command prompt.
# PROMPT_COMMAND is a special bash environment variable for the same purpose.
export PROMPT_COMMAND=sp
# Initialize it the first time:
sp
# alongside this, I’ve also implemented forward and back commands for directories as we are used to them in web browsers, so after the session at the beginning, I could say:
# [mymachine bar/baz]$ b
# [mymachine foo/bar]$ b
# [mymachine ~/foo]$ f
# [mymachine foo/bar]$ cd /usr/local/lib
# [mymachine local/lib]$ b
# [mymachine foo/bar]$
# If anyone is interested, I’m happy to post the code for that.
# $HOME/._cdd_add
echo ‘$_=$ENV{PWDx};split/:/;if($_[0]>1){$_[0]–};print(join(q{:},@_));’ > $HOME/._cdd_back
echo ‘$_=$ENV{PWDx};split/:/;print($_[$_[0]]);’ > $HOME/._cdd_curd
echo ‘$_=$ENV{PWDx};split/:/;if($_[0] $HOME/._cdd_forw
function cdd () { \cd $*; export PWDx=`perl $HOME/._cdd_add “$PWD”`; }
function b () { export PWDx=`perl $HOME/._cdd_back`; \cd “`perl $HOME/._cdd_curd`”; }
function f () { export PWDx=`perl $HOME/._cdd_forw`; \cd “`perl $HOME/._cdd_curd`”; }
alias cd=cdd
fi
#>
# I should mention that the idea and initial implementation for the two-level command prompt were from Jason A. Haynes for tcsh:
# “; if (“$hd:h” == “”) set prompt=”%m $pwd%# “; unset hd’
# alias sp ‘set pwd=`dirs`; set hd=$pwd:h; set prompt=”%m ..$hd:t/$pwd:t%
# Grem
# Ack! Part of the Historical Directory Browsing was cut off. Let me try again:
# $HOME/._cdd_add
echo ‘$_=$ENV{PWDx};split/:/;if($_[0]>1){$_[0]–};print(join(q{:},@_));’ > $HOME/._cdd_back
echo ‘$_=$ENV{PWDx};split/:/;print($_[$_[0]]);’ > $HOME/._cdd_curd
echo ‘$_=$ENV{PWDx};split/:/;if($_[0] $HOME/._cdd_forw
function cdd () { \cd $*; export PWDx=`perl $HOME/._cdd_add “$PWD”`; }
function b () { export PWDx=`perl $HOME/._cdd_back`; \cd “`perl $HOME/._cdd_curd`”; }
function f () { export PWDx=`perl $HOME/._cdd_forw`; \cd “`perl $HOME/._cdd_curd`”; }
alias cd=cdd
fi
#Oh, I see, it wasn’t so much “cut off” as hidden by angle brackets.
# historical directory browsing
# Historical directory browsing adds `b’ and `f’ commands to your shell
# to let you go back and forward in your directory history like you
# go back and forward in your web page browsing history.
# Idea and original implementation from Deniz Yuret, rewritten by Gremio
if [ ! -n “$PWDx” ]; then
export PWDx=”1:`pwd`”
echo ‘$_=$ENV{PWDx};split/:/;$_[++$_[0]]=shift;splice(@_,$_[0]+1);print(join(q{:},@_));’ > $HOME/._cdd_add
echo ‘$_=$ENV{PWDx};split/:/;if($_[0]>1){$_[0]–};print(join(q{:},@_));’ > $HOME/._cdd_back
echo ‘$_=$ENV{PWDx};split/:/;print($_[$_[0]]);’ > $HOME/._cdd_curd
echo ‘$_=$ENV{PWDx};split/:/;if($_[0] $HOME/._cdd_forw
function cdd () { \cd $*; export PWDx=`perl $HOME/._cdd_add “$PWD”`; }
function b () { export PWDx=`perl $HOME/._cdd_back`; \cd “`perl $HOME/._cdd_curd`”; }
function f () { export PWDx=`perl $HOME/._cdd_forw`; \cd “`perl $HOME/._cdd_curd`”; }
alias cd=cdd
fi
Perhaps it’s because when I’m at an actual prompt, I’m at home, not working, I find all the stuff about current directory, user, hostname, et cetera, just extraneous. So generally my prompt is just
PS1=’\$ ‘
If I need to know stuff, there’s always pwd, hostname, and whoami.
Please help with this advice apticeraped?I really dont know what to do or ?How to resolve this, Your help or advice would be great. Please be sensitive as I am feeling quite low.Back in 2005 an abusive ex was arrested for beating up another woman, he was immediately given 15 months in prison (he did 9 months of the sentence) not only was I appalled at his actions, but it meant he had cheated/lied to me to have been with her. This was my que to have a fresh start. I was working at a gym, did an access to nursing course (worked very hard to study and have a job and manage my flat, finances etc) I also met a great guy that I worked with. I wrote to the bad guy in prison and told him I had moved on. For once I was happy. Me and the new man had a great few months, I was enjoying my studies, got in to an amazing nursing college, was happy and getting self esteem back and this new guy treated me great. In June 06, the toxic man was released from prison (I had ignored his calls and letter) he knew I was in a relationship. Yet, still turned up at my home un invited. He could see I was going places, was happy and had moved on. He was trying every trick in the book to win me back but I told him I was with someone and happy. He didnt listen. In Sept 06 he came to my home and violently raped me. I have had psychological counselling. But because of what he did I pushed the good guy away. I didnt even tell him what had happened as I was too ashamed. Eventually at some point in 2007 our relationship fizzled (down to me being down, unreliable and not myself). Yet, it was only in 2008 that I came forward to police about the rape and abuse as I was not ready to deal with it until then. I had left my University nursing course, I had depression and frankly my life was a mess (still is). The rape trial was due to be 22nd Feb this year, but due to police negligence (they lost one of my video statements) and a catalogue of errors the case was thrown out of court by the judge! Not only has this man destroyed my life and saw that I was moving on and happy and did what he could to ruin it, but he walks free from court for what he did. The nice guy has moved on and is engaged and happy, and I am left picking up the pieces of my life. The last 4 years have been sheer hell. I had a brief relationship in the summer and I am now 7 months pregnant, I just feel like my life is a total mess and dont know what to do to get back to my old self.I am currently in the process of suing the police but the injustice of all this is awful Please help, thanksthe length of time it took me to report the rape is irrelevent as I forgot to mention I had visited a rape clinic straight after where forensics and medical evidence were taken and a DNA match was found. I havent spoken to this beast for 18 months and dont intend to.
Mine is ever so slightly more complicated than yours:
PROMPT=$’%(!.%F{red}.%F{blue})%D{%a %R} %B[%m:%35<..<%~%<<] %n%#%b%f '
RPROMPT=$'%(!.%F{red}.%F{blue})<%(1j. %BJ%j%b.)%f'
if (( $SHLVL != ${ZSHLVL:=$SHLVL} ))
then
RPROMPT=$RPROMPT$' %F{magenta}Z'$(( $SHLVL – $ZSHLVL ))$'%f'
fi
export ZSHLVL
# Set colorful PS1 only on colorful terminals
NORMAL=”\[33[0;0m\]”
BOLD=”\[33[1m\]”
BLUE=”\[33[0;34m\]”
CYAN=”\[33[0;36m\]”
BRIGHT_CYAN=”\[33[1;36m\]”
DIM_CYAN=”\[33[2;36m\]”
WHITE=”\[33[1;37m\]”
PS1=”$BLUE[$CYAN\u@\h:\w$BLUE]\n$BLUE[$CYAN\t$BLUE]$BOLD\$$NORMAL “
PS1=”[\[33[32m\]\w]\[33[0m\]\n\[33[1;36m\]\u\[33[1;33m\] -> \[33[0m\]”
My PS1 is different depending on the environment.
In normal terminal session it is: \h:\w \u\$
But within Emacs (where most of my shell work is) it is simply: [\t] \$
# This prompt has the hostname and up to two levels of directory context. Just one level often doesn’t disambiguate, and more than two is often annoying. So a session might go:
# [mymachine ~]$ cd foo
# [mymachine ~/foo]$ cd bar
# [mymachine foo/bar]$ cd baz
# [mymachine bar/baz]$
# The actual code:
echo ‘($H)=($ENV{HOST}=~/([^\.]+ /);s|$ENV{HOME}|~|g;s|.+/([^/]+/[^/]+)$| ${1}|g;s|^|$H |;’ > $HOME/._sp
# Running it:
function sp () { PS1=”[`pwd | perl -p $HOME/._sp`]\$ “; }
# Install it into the prompt:
# precmd is a special tcsh alias executed before every command prompt.
# PROMPT_COMMAND is a special bash environment variable for the same purpose.
export PROMPT_COMMAND=sp
# Initialize it the first time:
sp
# alongside this, I’ve also implemented forward and back commands for directories as we are used to them in web browsers, so after the session at the beginning, I could say:
# [mymachine bar/baz]$ b
# [mymachine foo/bar]$ b
# [mymachine ~/foo]$ f
# [mymachine foo/bar]$ cd /usr/local/lib
# [mymachine local/lib]$ b
# [mymachine foo/bar]$
# If anyone is interested, I’m happy to post the code for that.
Gregory:
That would be nice. Thanks.
# $HOME/._cdd_add
echo ‘$_=$ENV{PWDx};split/:/;if($_[0]>1){$_[0]–};print(join(q{:},@_));’ > $HOME/._cdd_back
echo ‘$_=$ENV{PWDx};split/:/;print($_[$_[0]]);’ > $HOME/._cdd_curd
echo ‘$_=$ENV{PWDx};split/:/;if($_[0] $HOME/._cdd_forw
function cdd () { \cd $*; export PWDx=`perl $HOME/._cdd_add “$PWD”`; }
function b () { export PWDx=`perl $HOME/._cdd_back`; \cd “`perl $HOME/._cdd_curd`”; }
function f () { export PWDx=`perl $HOME/._cdd_forw`; \cd “`perl $HOME/._cdd_curd`”; }
alias cd=cdd
fi
#>
# I should mention that the idea and initial implementation for the two-level command prompt were from Jason A. Haynes for tcsh:
# “; if (“$hd:h” == “”) set prompt=”%m $pwd%# “; unset hd’
# alias sp ‘set pwd=`dirs`; set hd=$pwd:h; set prompt=”%m ..$hd:t/$pwd:t%
# Grem
# Ack! Part of the Historical Directory Browsing was cut off. Let me try again:
# $HOME/._cdd_add
echo ‘$_=$ENV{PWDx};split/:/;if($_[0]>1){$_[0]–};print(join(q{:},@_));’ > $HOME/._cdd_back
echo ‘$_=$ENV{PWDx};split/:/;print($_[$_[0]]);’ > $HOME/._cdd_curd
echo ‘$_=$ENV{PWDx};split/:/;if($_[0] $HOME/._cdd_forw
function cdd () { \cd $*; export PWDx=`perl $HOME/._cdd_add “$PWD”`; }
function b () { export PWDx=`perl $HOME/._cdd_back`; \cd “`perl $HOME/._cdd_curd`”; }
function f () { export PWDx=`perl $HOME/._cdd_forw`; \cd “`perl $HOME/._cdd_curd`”; }
alias cd=cdd
fi
#Oh, I see, it wasn’t so much “cut off” as hidden by angle brackets.
# historical directory browsing
# Historical directory browsing adds `b’ and `f’ commands to your shell
# to let you go back and forward in your directory history like you
# go back and forward in your web page browsing history.
# Idea and original implementation from Deniz Yuret, rewritten by Gremio
if [ ! -n “$PWDx” ]; then
export PWDx=”1:`pwd`”
echo ‘$_=$ENV{PWDx};split/:/;$_[++$_[0]]=shift;splice(@_,$_[0]+1);print(join(q{:},@_));’ > $HOME/._cdd_add
echo ‘$_=$ENV{PWDx};split/:/;if($_[0]>1){$_[0]–};print(join(q{:},@_));’ > $HOME/._cdd_back
echo ‘$_=$ENV{PWDx};split/:/;print($_[$_[0]]);’ > $HOME/._cdd_curd
echo ‘$_=$ENV{PWDx};split/:/;if($_[0] $HOME/._cdd_forw
function cdd () { \cd $*; export PWDx=`perl $HOME/._cdd_add “$PWD”`; }
function b () { export PWDx=`perl $HOME/._cdd_back`; \cd “`perl $HOME/._cdd_curd`”; }
function f () { export PWDx=`perl $HOME/._cdd_forw`; \cd “`perl $HOME/._cdd_curd`”; }
alias cd=cdd
fi
Found that bash on Solaris doesn’t like that PS1…. here is the updated version:
PS1=’\u@\h:\W>’
Perhaps it’s because when I’m at an actual prompt, I’m at home, not working, I find all the stuff about current directory, user, hostname, et cetera, just extraneous. So generally my prompt is just
PS1=’\$ ‘
If I need to know stuff, there’s always pwd, hostname, and whoami.
I do not claim any proper code in the following lines that I’ve had for ages…
%cat load.zsh
#!/bin/zsh
declare -i Up=”`uptime | awk -F: ‘{print $4}’ | cut -f1 -d’,’`”
if [ $Up -ge 2 ]
then
echo ‘red’
exit
else
if [ $Up -lt 1 ]
then
echo ‘green’
exit
else
echo ‘yellow’
exit
fi
fi
%cat prompt.zsh
autoload -U colors
colors
user_color=”cyan”
user_in_color=”white”
path_color=”green”
percent_color=”yellow”
date_color=”`zsh ~/.zsh/load.zsh`”
date_format=”%H:%M”
#start=”%U”
date=”%{$fg[$date_color]%}%D{$date_format}”
user=”%{$fg[$user_color]%}[%{$fg[$user_in_color]%}%n%{$fg[$user_color]%}]”
cpath=”%B%{$fg[$path_color]%}%~%b”
percent=”%{$fg[$percent_color]%}%%”
end=”%{$reset_color%}”
PS1=”$user$cpath $percent$end ”
RPS1=”$date$end”
PS1=”[\u@\h \W]\\$ “
Please help with this advice apticeraped?I really dont know what to do or ?How to resolve this, Your help or advice would be great. Please be sensitive as I am feeling quite low.Back in 2005 an abusive ex was arrested for beating up another woman, he was immediately given 15 months in prison (he did 9 months of the sentence) not only was I appalled at his actions, but it meant he had cheated/lied to me to have been with her. This was my que to have a fresh start. I was working at a gym, did an access to nursing course (worked very hard to study and have a job and manage my flat, finances etc) I also met a great guy that I worked with. I wrote to the bad guy in prison and told him I had moved on. For once I was happy. Me and the new man had a great few months, I was enjoying my studies, got in to an amazing nursing college, was happy and getting self esteem back and this new guy treated me great. In June 06, the toxic man was released from prison (I had ignored his calls and letter) he knew I was in a relationship. Yet, still turned up at my home un invited. He could see I was going places, was happy and had moved on. He was trying every trick in the book to win me back but I told him I was with someone and happy. He didnt listen. In Sept 06 he came to my home and violently raped me. I have had psychological counselling. But because of what he did I pushed the good guy away. I didnt even tell him what had happened as I was too ashamed. Eventually at some point in 2007 our relationship fizzled (down to me being down, unreliable and not myself). Yet, it was only in 2008 that I came forward to police about the rape and abuse as I was not ready to deal with it until then. I had left my University nursing course, I had depression and frankly my life was a mess (still is). The rape trial was due to be 22nd Feb this year, but due to police negligence (they lost one of my video statements) and a catalogue of errors the case was thrown out of court by the judge! Not only has this man destroyed my life and saw that I was moving on and happy and did what he could to ruin it, but he walks free from court for what he did. The nice guy has moved on and is engaged and happy, and I am left picking up the pieces of my life. The last 4 years have been sheer hell. I had a brief relationship in the summer and I am now 7 months pregnant, I just feel like my life is a total mess and dont know what to do to get back to my old self.I am currently in the process of suing the police but the injustice of all this is awful Please help, thanksthe length of time it took me to report the rape is irrelevent as I forgot to mention I had visited a rape clinic straight after where forensics and medical evidence were taken and a DNA match was found. I havent spoken to this beast for 18 months and dont intend to.