DaemonForums  

Go Back   DaemonForums > Miscellaneous > General software and network

General software and network General OS-independent software and network questions, X11, MTA, routing, etc.

Reply
 
Thread Tools Display Modes
  #1   (View Single Post)  
Old 18th October 2008
bsddaemon bsddaemon is offline
Slack Daemon
 
Join Date: Oct 2008
Posts: 35
Default Exec command in zsh prompt?

Hi everyone. Im using laptop with FreeBSD. What Im trying to do is to display the remaining capacity and time in the shell prompt.

It is easily achieved with bash, but in zsh, the command is only executed upon startup.

This is a bash prompt in the .bashrc file. I use the date command as an example. The current time will be updated everytime you exec new command:

Code:
PS1='`date +'%H:%M:%S'` \!\[\e[1;31m\][\[$?]\[\e[37m\]\u@\h:\w\\$ '
This method doesnt work with zsh. If I put a similar command in .zshrc, it will show the current time on startup only, after that, the time is not updated at all.
Reply With Quote
  #2   (View Single Post)  
Old 18th October 2008
bsddaemon bsddaemon is offline
Slack Daemon
 
Join Date: Oct 2008
Posts: 35
Default

Ah, nvm, I found it. It is precmd
Reply With Quote
  #3   (View Single Post)  
Old 18th October 2008
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,125
Default

Under the OpenBSD ksh the following works
Code:
PS1="\$(date +'%H:%M:%S')"  
23:24:31
23:24:35
23:24:35sleep 60
23:25:44
23:29:23
23:29:52
Instead of using backticks, I use the $( ..... )construct. To prevent it from executing at read/compile time, the leading dollar sign is escaped with a '\'.
Because '\' only works when the shell gets to interpret it, double quotes (") were used instead of single quotes (').
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Nicer Prompt with ksh on 5.0 nihonto NetBSD Installation and Upgrading 8 12th October 2009 08:49 PM
backup freeBSD 7.0 using Backup Exec ccc FreeBSD General 2 25th April 2009 09:23 PM
changing custom prompt ksh for root. bsdnewbie999 OpenBSD General 7 1st April 2009 04:53 AM
init: can't exec getty after power failure mtx FreeBSD General 0 20th January 2009 10:14 AM
what to do at mountroot prompt? Sunsawe FreeBSD General 13 5th June 2008 08:06 AM


All times are GMT. The time now is 06:03 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content copyright © 2007-2010, the authors
Daemon image copyright ©1988, Marshall Kirk McKusick