LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 10-07-2003, 01:23 AM   #1
dekket
Member
 
Registered: Oct 2003
Location: sweden
Distribution: debian
Posts: 47

Rep: Reputation: 15
uptime in bash prompt


I was bored today, so I thought I'd make an uptime script for use in my prompt. I fiddled with grep etc, but I cant make it work when uptime goes from 9 -> 10, 99 -> 100 etc...
So.. does anyone else know?

Another question; anyone have a solution to how I can make the width of Current Working Directory dynamic and make it print only the last 45 chracters of the directory or so? Its annoying when my lovely prompt look shitty because the directory is 150 chars long... ;>

thx for any help.
 
Old 10-07-2003, 02:54 AM   #2
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
maybe you can set a variable to what you want to use then use it to set the prompt.


for the working dir try `basename pwd`

VAR=`pwd`
VAR=`basename $VAR`
 
Old 10-07-2003, 01:18 PM   #3
dekket
Member
 
Registered: Oct 2003
Location: sweden
Distribution: debian
Posts: 47

Original Poster
Rep: Reputation: 15
uhm... but how does that help me control the width of the Current Working Directory?
 
Old 10-07-2003, 01:39 PM   #4
DavidPhillips
LQ Guru
 
Registered: Jun 2001
Location: South Alabama
Distribution: Fedora / RedHat / SuSE
Posts: 7,163

Rep: Reputation: 58
it will show the directory only, not the path

basename /var/spool/mail/david
david


It is also in the default PS1 used by most systems


\w means `pwd`

\W means `basename pwd`

http://new.linuxnow.com/docs/content...t-HOWTO-2.html

Last edited by DavidPhillips; 10-07-2003 at 01:50 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
bash prompt subG Slackware 6 01-18-2006 05:43 PM
Changing the BASH prompt? Dravis Linux - Software 2 01-22-2004 10:17 PM
help with bash prompt everythingand2 Linux - Newbie 7 12-06-2003 05:28 PM
Bash Prompt mandraketux Mandriva 2 11-28-2003 11:05 PM
'uptime' bash script icyfire Linux - Software 4 01-10-2003 06:53 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 07:55 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration