LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 10-28-2007, 09:37 PM   #1
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Rep: Reputation: 37
Remove file location from bash line


Sorry but I am not sure how to phrase this.
I have slack12.
At the bash line in Konsole your file location is shown. When there are several subfiles the bash line can get quite long.

For example
fred@bt:/home/fred/download/mp3s/musician/album/song$

By the time you enter the command, you are on the right side of the screen.
1.How can you remove the file location from the commandline?
2. How can you make the file location re-appear?
3. What is the command to show where you are?

Thanks
okos
 
Old 10-28-2007, 09:58 PM   #2
dxqcanada
Member
 
Registered: Sep 2006
Location: Canada
Distribution: Gentoo
Posts: 702

Rep: Reputation: 43
Hmmm, most likely your /etc/profile has the prompt set to
Code:
PS1='\u@\h \w \$ '
The \w prints the working directory.

You would have to change this.
You could modify your .bashrc to change the prompt whenever you log in.

You could also just issue
Code:
PS1='\u@\h \$ '
at your command prompt.

To show your working directly use the "pwd" command.
 
Old 10-28-2007, 10:34 PM   #3
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Original Poster
Rep: Reputation: 37
That worked!
Is there a way to temporarily remove the file location?
A less permanent solution?
 
Old 10-29-2007, 02:27 AM   #4
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,036

Rep: Reputation: 96
Quote:
Originally Posted by dxqcanada View Post
You could also just issue
Code:
PS1='\u@\h \$ '
at your command prompt.
As dxcanada says, you can set PS1 from the command line, this would only affect the current shell, then you could always set it back to:
Code:
PS1='\u@\h:\w \$ '
Alternativley, you could change your PS1 to drop down to the next line:
Code:
PS1='\u@\h:\w\n> '
example:
Code:
disillusionist@ubuntu:/my/very/long/path/to/working/files/example
>
 
Old 10-30-2007, 01:07 AM   #5
okos
Member
 
Registered: May 2007
Location: California
Distribution: Slackware/Ubuntu
Posts: 609

Original Poster
Rep: Reputation: 37
If you wanted to set it as an alias would the syntax be:
alias ps1="PS1='\u@\h \$ '"
since alias requires quotes would this work?
 
Old 10-30-2007, 03:46 AM   #6
Disillusionist
Senior Member
 
Registered: Aug 2004
Location: England
Distribution: Ubuntu
Posts: 1,036

Rep: Reputation: 96
Quote:
Originally Posted by okos View Post
If you wanted to set it as an alias would the syntax be:
alias ps1="PS1='\u@\h \$ '"
since alias requires quotes would this work?
Works for me.

I would also create an alias ops1
alias ops1="PS1='\u@\h:\w '"

If these lines are added to your .profile and .bashrc files then they should be available when you start your terminal session.

ps1 would remove the working directory
ops1 would add the working directory back (old PS1)
 
  


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 shell script read file line by line. Darren[UoW] Programming 57 04-17-2016 07:07 PM
Bash remove part of a file based on contents of another file bhepdogg Programming 4 01-31-2007 04:13 PM
file processing -- remove the first column of each line George2 Programming 7 11-19-2006 10:15 AM
PERL:: trying to remove last line of file ocularbob Programming 16 09-01-2003 02:07 PM
How to remove line of text from file netkepala Linux - General 2 05-23-2003 12:49 PM


All times are GMT -5. The time now is 06:09 AM.

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