You are not logged in.
Hey!
How do I do so I run a fortune quote when my urxvt term opens? I have seen this on for example Smoons desktops And it looks very nice
// Kris
"Penquins, Penquins, über alles!"
Offline
I've got the following at the end of my .zshrc:
if which fortune &> /dev/null ; then
echo "e[1;31m`fortune`e[0m"
echo ""
fi
It checks if fortune (the program to show the quotes; package to install is fortune-mod) is in $PATH and just echos it's output if found.
echo "`fortune`"
will work just fine if fortune is installed. This should work in a .bashrc as well.
Offline
Can't you just do
`which fortune`
in .bashrc? If it finds fortune, it runs it. If it doesn't, nothing gets outputted.
Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB
Offline
Can't you just do
`which fortune`
in .bashrc? If it finds fortune, it runs it. If it doesn't, nothing gets outputted.
thats just exactly what the little if-script does, just leave out the zsh parts so it looks lie this
if which fortune &> /dev/null ; then
echo "`fortune`"
echo ""
fi
^-- checks if fortune is present, and then 'starts' it
cheers,
detto
Offline
thats just exactly what the little if-script does
Which mine does in two words, no if statement required
Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB
Offline
detto wrote:thats just exactly what the little if-script does
Which mine does in two words, no if statement required
Plus you get a nice error message if fortune isn't found by which
Offline
Can't you just do
`which fortune`
in .bashrc? If it finds fortune, it runs it. If it doesn't, nothing gets outputted.
If it finds <code>fortune</code>, it would not run it, but return its location. If it is not found, it would return an error message.
Offline
detto @
It works great - but I must use .bash_profile, .bashrc don't have effect...
smoon @
I have seen that you - in the Show Your Desktop-thread - havde changed the default name/HOSTNAME-thing How do you make that?
// Kris
"Penquins, Penquins, über alles!"
Offline
chrismortimore wrote:Can't you just do
`which fortune`
in .bashrc? If it finds fortune, it runs it. If it doesn't, nothing gets outputted.
If it finds <code>fortune</code>, it would not run it, but return its location. If it is not found, it would return an error message.
If you prefix it with an echo this is true. If you just run `which fortune` it will run the result of `which fortune' which is either the full path to fortune if found, or an error message if fortune isn't in $PATH - and honestly, running an error message is not the best idea
[...]
smoon @
I have seen that you - in the Show Your Desktop-thread - havde changed the default name/HOSTNAME-thing How do you make that?
It's the environment variable PS1 in http://hg.nooms.de/dotfiles?f=0aebb8fe2 … yle=gitweb that is responsible for that.
Offline
If it finds <code>fortune</code>, it would not run it, but return its location. If it is not found, it would return an error message.
Note the ` and the ` around the command, once it finds the command, it executes the string, as in the location of the executable.
Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB
Offline
smoon @
35 # exports
36 ###
37 if [ "$HOST" != "twoflower" ] ; then
38 _h="@$HOST"
39 fi
40 if [ $UID -eq 0 ] ; then
41 export PS1=$' %{e[1;31m%}%n@%m:%{e[1;32m%}%~ %{e[1;31m%}%#%{e[0m%} '
42 else
43 export PS1=$' %{e[1;34m%}%n'$_h$':%{e[1;32m%}%~ %{e[1;34m%}%#%{e[0m%} '
44 fi
This?[/code]
// Kris
"Penquins, Penquins, über alles!"
Offline
Consider adding this check-up to avoid problems with some terms:
if [ $TERM != "dumb" ]; then `which fortune`; fi
Offline
smoon @
35 # exports 36 ### 37 if [ "$HOST" != "twoflower" ] ; then 38 _h="@$HOST" 39 fi 40 if [ $UID -eq 0 ] ; then 41 export PS1=$' %{e[1;31m%}%n@%m:%{e[1;32m%}%~ %{e[1;31m%}%#%{e[0m%} ' 42 else 43 export PS1=$' %{e[1;34m%}%n'$_h$':%{e[1;32m%}%~ %{e[1;34m%}%#%{e[0m%} ' 44 fi
This?[/code]
Yeah, the PS1 stuff. The first one is red and looks like this
root@host:/pwd %
The secocnd one is blue and looks like
user:/pwd %
Offline
Consider adding this check-up to avoid problems with some terms:
if [ $TERM != "dumb" ]; then `which fortune`; fi
What terminals are "dumb" and why are they unable to print out text?
Offline
What terminals are "dumb" and why are they unable to print out text?
Offline
elasticdog wrote:If it finds <code>fortune</code>, it would not run it, but return its location. If it is not found, it would return an error message.
Note the ` and the ` around the command, once it finds the command, it executes the string, as in the location of the executable.
Doh...didn't read carefully. :oops:
Offline
Doh...didn't read carefully. :oops:
I'll let you off this time
Desktop: AMD Athlon64 3800+ Venice Core, 2GB PC3200, 2x160GB Maxtor DiamondMax 10, 2x320GB WD Caviar RE, Nvidia 6600GT 256MB
Laptop: Intel Pentium M, 512MB PC2700, 60GB IBM TravelStar, Nvidia 5200Go 64MB
Offline
Kris wrote:smoon @
35 # exports 36 ### 37 if [ "$HOST" != "twoflower" ] ; then 38 _h="@$HOST" 39 fi 40 if [ $UID -eq 0 ] ; then 41 export PS1=$' %{e[1;31m%}%n@%m:%{e[1;32m%}%~ %{e[1;31m%}%#%{e[0m%} ' 42 else 43 export PS1=$' %{e[1;34m%}%n'$_h$':%{e[1;32m%}%~ %{e[1;34m%}%#%{e[0m%} ' 44 fi
This?[/code]
Yeah, the PS1 stuff. The first one is red and looks like this
root@host:/pwd %
The secocnd one is blue and looks like
user:/pwd %
Hmm... I think that zsh gives a different output than BASH
[code]
%{%}%n@:%{%}%~ %{%}%#%{%}
[/code]
// Kris
"Penquins, Penquins, über alles!"
Offline
smoon wrote:Kris wrote:smoon @
35 # exports 36 ### 37 if [ "$HOST" != "twoflower" ] ; then 38 _h="@$HOST" 39 fi 40 if [ $UID -eq 0 ] ; then 41 export PS1=$' %{e[1;31m%}%n@%m:%{e[1;32m%}%~ %{e[1;31m%}%#%{e[0m%} ' 42 else 43 export PS1=$' %{e[1;34m%}%n'$_h$':%{e[1;32m%}%~ %{e[1;34m%}%#%{e[0m%} ' 44 fi
This?[/code]
Yeah, the PS1 stuff. The first one is red and looks like this
root@host:/pwd %
The secocnd one is blue and looks like
user:/pwd %Hmm... I think that zsh gives a different output than BASH
[code]
%{%}%n@:%{%}%~ %{%}%#%{%}
[/code]
Hmm, yeah. There are some differences in Bash (I forgot about that).
%{e[1;31m%} for zsh is [033[1;31m] in bash, whereas 033[ is the indicator for a following escape sequence (e[ should work as well), 1;31 is the colorcode (1 for bold and 31 for red; there's more like underline etc. which you can combine) and m to mark the end of the escape sequence. The [ and ] around that are to tell bash that the characters inside of these braces are not printed out, if you don't put the escape sequences in these bash will get confused about the length of your prompt. If you want to know more just search the intarweb, you'll find plenty of information about this topic there.
Edit: The %n, %m, etc. are different in Bash as well. For example %n is the current user in zsh, in Bash it is u. Have a look at the bash manpage to find out about the available backslash-escaped special characters, the topic is PROMPTING.
Offline
Kris wrote:smoon wrote:Kris wrote:smoon @
35 # exports 36 ### 37 if [ "$HOST" != "twoflower" ] ; then 38 _h="@$HOST" 39 fi 40 if [ $UID -eq 0 ] ; then 41 export PS1=$' %{e[1;31m%}%n@%m:%{e[1;32m%}%~ %{e[1;31m%}%#%{e[0m%} ' 42 else 43 export PS1=$' %{e[1;34m%}%n'$_h$':%{e[1;32m%}%~ %{e[1;34m%}%#%{e[0m%} ' 44 fi
This?[/code]
Yeah, the PS1 stuff. The first one is red and looks like this
root@host:/pwd %
The secocnd one is blue and looks like
user:/pwd %Hmm... I think that zsh gives a different output than BASH
[code]
%{%}%n@:%{%}%~ %{%}%#%{%}
[/code]Hmm, yeah. There are some differences in Bash (I forgot about that).
%{e[1;31m%} for zsh is [033[1;31m] in bash, whereas 033[ is the indicator for a following escape sequence (e[ should work as well), 1;31 is the colorcode (1 for bold and 31 for red; there's more like underline etc. which you can combine) and m to mark the end of the escape sequence. The [ and ] around that are to tell bash that the characters inside of these braces are not printed out, if you don't put the escape sequences in these bash will get confused about the length of your prompt. If you want to know more just search the intarweb, you'll find plenty of information about this topic there.
Edit: The %n, %m, etc. are different in Bash as well. For example %n is the current user in zsh, in Bash it is u. Have a look at the bash manpage to find out about the available backslash-escaped special characters, the topic is PROMPTING.
[code]
# Exports
if [ "$HOST" != "twoflower" ] ; then
_h="@$HOST"
fi
if [ $UID -eq 0 ] ; then
export PS1=$' [033[1;31m]%n@%m:[1;32m]%~ [1;31m]%#[0m] '
else
export PS1=$' [1;34m]%n'$_h$':[1;32m]%~ [1;34m]%#[0m] '
fi
[/code]
Like this? It give also a weird output
// Kris
"Penquins, Penquins, über alles!"
Offline