How to change display in shell


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers How to change display in shell
# 1  
Old 07-16-2010
How to change display in shell

Hi

The line for input of my shell currently looks like in the image attached. What I wanted is for the line where I input, it showed in last, the folder I'm in (in the attached images is "Documents") and not my user name "Pedro_Gordo". How do I do this?

My OS is Mac OS X 10.6.

Thanks in advance

PS: I know I asked a very basic question for which there is probably already an answer, but I don't know the terms for which to look, if you could just tell me where to look, it's good too Smilie
How to change display in shell-captura-de-ecra-2010-07-17-030946png
# 2  
Old 07-16-2010
Hi.

Look for PS1 in the man page for the shell you are using (i.e. bash, ksh, etc.)

Example in Bash:
Code:
bash-3.2$[/COLOR] PS1='some long-winded command prompt string..... '
some long-winded command prompt string..... echo Hello
Hello
some long-winded command prompt string..... PS1='\W $ '
~ $ cd scripts
scripts $ cd tmp
tmp $

Here's one link I found... How to Customize your Terminal Prompt - OS X Daily

Last edited by Scott; 07-16-2010 at 10:57 PM..
This User Gave Thanks to Scott For This Post:
# 3  
Old 07-17-2010
set PS1 variable like this -

PS1="$PWD !$"

This will set your prompt like this -

<path of the current dir you are in> <line number>$

e.g:
/ms/user/r/rujuraha/exercise 12$
# 4  
Old 07-17-2010
Quote:
Originally Posted by rujuraha
set PS1 variable like this -
PS1="$PWD !$"
There are 2 errors in the above command, first one is

1) $PWD should be included only between single quotes and not in double quotes.

2) '!$' in bash shell shows the last input char string of command line present in the history.

Better use,
Code:
export PS1='\u@\h \w\$ '

(in bash, ksh)
Code:
set prompt = "%m%/% "

(in csh)
# 5  
Old 07-17-2010
It worked. Smilie But now I want it do have this prompt by default, so I added "PS1='\W $ '" to my bashrc file. However it doesn't do anything. Do I need it to put it other form in bashrc so it shows the prompt I want every time I open a shell?

What can I add to bashrc so the prompt stays like this:
[computer I'm working on, changing this if I'm working on a remote computer]: [folder I'm in (the PS1 thing)] $
# 6  
Old 07-17-2010
Hi.

Not sure what you mean by:

Quote:
Originally Posted by tirwit
[computer I'm working on, changing this if I'm working on a remote computer]: [folder I'm in (the PS1 thing)] $
Your .bashrc (with the dot, that you didn't mention) is loaded from your .bash_profile

Code:
$ head -6 .bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

Code:
$ grep PS1 .bashrc
PS1='\W $ '

Code:
/root # bash
~ $ cd /tmp
tmp $

# 7  
Old 07-17-2010
By
Quote:
[computer I'm working on, changing this if I'm working on a remote computer]: [folder I'm in (the PS1 thing)] $
I meant that in the first brackets should be the computer I'm working on, for example:
My_Macbook:~ $

And if I establish a VPN (to Paul's computer, for example), it stays:
Paul's_Macbook:~ $

Got it?

How can I open my .bash_profile to edit, since it's hidden? My OS is Snow Leopard 10.6, and my .bashrc file looks like this:

Code:
PS1='\W $'

# root
export ROOTSYS=/Users/Shared/root

export PATH=/bin:/sbin:/usr/bin:/usr/sbin:/Applications:$ROOTSYS/bin:/usr/local/bin

# root
export LD_LIBRARY_PATH=$ROOTSYS/lib:$LD_LIBRARY_PATH
export DYLD_LIBRARY_PATH=$ROOTSYS/lib:$DYLD_LIBRARY_PATH

 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Emergency UNIX and Linux Support

Change the display format for ls -l command in AIX

Hi, I am using AIX 5.3. In my server if I list the file , I got the below result in below format. ********************************************* -rw-rw--w- 1 letapp1 staff 0 Jun 8 02:53 CC00030710.cntrl ********************************************* But now I am seeing... (22 Replies)
Discussion started by: puni
22 Replies

2. AIX

Change AIX display resolution ?

Hello, Running X on AIX local display - want to change resolution. On Linux for example I used xrandr. ? thanks Vilius (1 Reply)
Discussion started by: vilius
1 Replies

3. Shell Programming and Scripting

how to change unix cmd display prompt?

I am new to to unix and I want to make my own basic shell. What is the code I can use to change the unix cmd console display? For example my unix display prompt says MyCompterName~, I want it to say WhatEverMan~ (3 Replies)
Discussion started by: megaearth77
3 Replies

4. Post Here to Contact Site Administrators and Moderators

Display Name change

Hi Currently my display name is "vasuarjula". Is there a way i can change my display name without changing my emailID and password. (2 Replies)
Discussion started by: vasuarjula
2 Replies

5. Post Here to Contact Site Administrators and Moderators

Change in display of date of postings

I would like to propose to change the display of dates in the postings, which is currently mm-dd-yy. To avoid ambiguity, I would like to propose dd-Mmm-yyyy. Thank you for your anticipated consideration. (5 Replies)
Discussion started by: figaro
5 Replies

6. UNIX for Dummies Questions & Answers

Cannot change my display to high resolution

Hi all, i am one of the newbies with linux. i just install the Enterprise AS on my ibm z60t. I am trying to change the color setting to hight resolution, unfortunately, it does not work. it works only with the 256 color setting. It seems the widescreen or the vga card of my notebook does not... (3 Replies)
Discussion started by: sanlen
3 Replies

7. UNIX for Dummies Questions & Answers

How to change display resolution in UnixV4.0D

I would like to know how to change the display resolution in UnixV4.0D. Can anyone please help me. Regards, Avgust (1 Reply)
Discussion started by: avgust
1 Replies

8. Solaris

How to change display resolution

Hi, I would like to know how to change the display resolution in solaris on sparc. Can anyone please help me. Regards, Raja (3 Replies)
Discussion started by: RajaRC
3 Replies

9. UNIX for Dummies Questions & Answers

Shell Script Display?

I remember learning that there is a way to make a shell script display the script itself to standard output while the script is being executed but I can't find how to do that. Any pointers? (2 Replies)
Discussion started by: wmosley2
2 Replies
Login or Register to Ask a Question