1

I want the shell of emacs show the absolute path. My system shell is config like following

export PS1='\u@MacAir:\w$ '

I have try this way. It can't work for me .

PS: My emacs is emacs24

Solution : Add export PS1='\u@MacAir:\w$ ' into ~/.bashrc

Community
  • 1
  • 1
Samuel
  • 5,977
  • 14
  • 55
  • 77

1 Answers1

3

The shell prompt is not the responsibility of Emacs but of the shell you're running. Assuming you're using bash, check out the following question+answer:

https://askubuntu.com/questions/388913/how-to-make-ps1-display-full-path-name

which recommends the use of the special escape sequence $PWD:

export PS1='\u@MacAir:$PWD$ '

Put the above line in your ~/.bashrc file for it to take effect in Emacs (as well as in normal terminals).

(A lot) more information can be found here: http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/

Community
  • 1
  • 1
Thomas
  • 17,016
  • 4
  • 46
  • 70
  • That only work for system's shell, Not the the shell of emacs – Samuel Aug 24 '15 at 11:55
  • 1
    Both shells are the same (bash). I've just tried out the following and it works without flaws: (1) Start Emacs; (2) type `M-x shell`; (3) in the shell, write `export PS1='\u@MacAir:$PWD$ '`. This gives the expected results. – Thomas Aug 24 '15 at 13:20
  • Yes. But where should I set the `export PS1='\u@MacAir:$PWD$ '`. I don't want to write that command everytime when I open a shell in emacs – Samuel Aug 25 '15 at 01:03
  • 1
    @Samuel -- Oh, sorry: since the link you provided in your original question already contains that information, I didn't include it in my answer. You should put that line in your `.bashrc` file in your `$HOME` directory, i.e., put it in `~/.bashrc`. – Thomas Aug 25 '15 at 09:33
  • Actually I had put that in my `/etc/bashrc`. But it only works for the system shell. It doesn't work when I call shell in emacs by `M+x shell`. – Samuel Aug 25 '15 at 12:45