Review your favorite Linux distribution.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 07-21-2012, 10:03 AM   #1
LQ Newbie
Registered: Jul 2012
Posts: 3

Rep: Reputation: Disabled
Question Make Bash prompt look like Windows C:\ prompt -- *PROBLEM*

So I am trying to have a Bash prompt emulate a windows cmd prompt as a little prank and need a little help. I am running in to a few errors and want to see if y'all can help with this. Here is what i have so far:

PROMPT_COMMAND='CurDir=`pwd | sed -r "s!$HOME!~!" | sed -r "s!/!\\!g"`'

PS1="C:\\$CurDir >"

#Here is the error that i am getting:

$ . .bashrc
sed: -e expression #1, char 7: unterminated `s' command
C:\ >

#What i am trying to have happen is:
So what I am trying to do is have the shell prompt show


at logon and with in the $HOME

now when you move around you see something like

C:\this\is\only\a\sample\ >

I know there is something that I am doing wrong, but I can't seem to figure it out.

when i run the this in the shell I see
$pwd | sed 's!/!\\!g'


So can y'all please help me with this issue..
I think that this would be a great prank to pull on someone who leaves their home shell open all the time..

## I have found many link for turning the cmd prompt to look like bash not the other way around..
Old 07-21-2012, 02:00 PM   #2
Senior Member
Registered: Jan 2010
Location: SI : 45.9531, 15.4894
Distribution: CentOS, OpenNA/Trustix, testing desktop openSuse 12.1 /Cinnamon/KDE4.8
Posts: 1,144

Rep: Reputation: 217Reputation: 217Reputation: 217
export PS1="\[\e[01;32m\]C\072\w \[\e[0m\]> "

you get:
C:~/Documents/emails >
don't use "sed"
BASH prompt how-to
changing Bash prompt

Last edited by lithos; 07-21-2012 at 02:33 PM.
1 members found this post helpful.
Old 07-21-2012, 04:22 PM   #3
LQ Newbie
Registered: Jul 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks, that does take me one step further..
so have run this and yes i see:
C:~/.mozilla > cd plugins/
C:~/.mozilla/plugins > cd
C:~ >
The reason i was using sed was so that that output would be something like:
C:~̇\mozilla > cd plugins/
C:~\mozilla\plugins > cd
C:~ >

Last edited by arkadios; 07-21-2012 at 04:25 PM.
Old 07-22-2012, 02:07 AM   #4
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 335

Rep: Reputation: 141Reputation: 141
This uses Bash Parameter Expansion.
PROMPT_COMMAND='PS1="${PWD/#$HOME/~}"; PS1="C:${PS1//\//\\\\} > "'

C:~ >
C:~ > cd /usr
C:\usr > cd share
C:\usr\share >
1 members found this post helpful.
Old 07-23-2012, 10:36 AM   #5
LQ 5k Club
Registered: Jan 2011
Location: Nowhere near you, thank God.
Distribution: OSX Sierra
Posts: 8,570
Blog Entries: 14

Rep: Reputation: Disabled
Been using this for years.

Last edited by Habitual; 07-24-2012 at 09:18 AM.
1 members found this post helpful.
Old 07-24-2012, 11:29 AM   #6
LQ Newbie
Registered: Jul 2012
Posts: 3

Original Poster
Rep: Reputation: Disabled
Thanks for all the help..
I have tried both from Kenhelm and Habitual which work great.


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

Similar Threads
Thread Thread Starter Forum Replies Last Post
passing parameters from a unix shell prompt into a windows cmd.exe prompt nano2 Programming 1 09-01-2009 11:26 AM
please help make my bash prompt color extendedping Linux - Software 4 04-02-2009 09:47 PM
bash prompt problem bjharker Linux - Newbie 5 07-18-2006 02:50 PM
bash prompt problem akudewan Slackware 7 03-09-2005 07:21 AM
make bash interactive and change prompt DropSig Linux - Newbie 3 05-17-2004 08:16 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:44 PM.

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