LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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.

Notices


Reply
  Search this Thread
Old 07-21-2012, 10:03 AM   #1
arkadios
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

C:~>

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'
\home\username\Downloads\note

____________________________________________________________

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
lithos
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
spoiler:
Code:
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
arkadios
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:
Code:
C:~/.mozilla > cd plugins/
C:~/.mozilla/plugins > cd
C:~ >
The reason i was using sed was so that that output would be something like:
Code:
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
Kenhelm
Member
 
Registered: Mar 2008
Location: N. W. England
Distribution: Mandriva
Posts: 360

Rep: Reputation: 170Reputation: 170
This uses Bash Parameter Expansion.
http://www.gnu.org/software/bash/man...eter-Expansion
Code:
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
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Code:
DOS='C:${PWD//\//\\\}>'
PS1="\[\033[00m\]\[\033[00m\]\[\033[01;39m\]$DOS\[\033[00m\]"
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
arkadios
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.
 
  


Reply



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

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 03:15 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
Open Source Consulting | Domain Registration