Under Ubuntu, by default, the absolute path is shown for the terminal, for example:
650) this.width=650; "title=" Terminal Show full path "style=" Border-top:0px;border-right:0px;background-image:none; border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" terminal show full Path "src=" http://i2.wp.com/www.crifan.com/files/pic/uploads/2013/08/terminal-show-full-path_thumb.png?resize= 615%2c333 "height=" 333 "width=" 615 "border=" 0 "/>
Now you want it to show only the relative path.
"Resolution Process"
Reference:
In Linux, remove the absolute path of the current directory displayed by the terminal
1. Enter the command first:
sudo vim ~/.BASHRC
Locate the. BASHRC, about the PS1 section, from:
If ["$color _prompt" = yes]; Then Ps1= ' ${debian_chroot:+ ($debian _chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[ 00m\]\$ ' Else Ps1= ' ${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$ ' Fi unset color_prompt Force_color_prompt # If This is a xterm set the title to [email protected]:d IR Case ' $TERM ' in xterm*|rxvt*) Ps1= "\[\e]0;${debian_chroot:+ ($debian _chroot)}\[email protected]\h: \w\a\] $PS 1″ ;; *) ;; Esac |
Switch
If ["$color _prompt" = yes]; Then Ps1= ' ${debian_chroot:+ ($debian _chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[ 00m\]\$ ' Else Ps1= ' ${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\w\$ ' Fi unset color_prompt Force_color_prompt # If This is a xterm set the title to [email protected]:d IR Case ' $TERM ' in xterm*|rxvt*) Ps1= "\[\e]0;${debian_chroot:+ ($debian _chroot)}\[email protected]\h: \W\a\] $PS 1″ ;; *) ;; Esac |
2. Save the changes and exit vim. Then source a bit and find the terminal's title becomes the current path:
650) this.width=650; "title=" after source title become short "style=" border-top:0px;border-right:0px;background-image : none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" after source Title become short "src=" http://i2.wp.com/www.crifan.com/files/pic/uploads/2013/08/ after-source-title-become-short_thumb.png?resize=615%2c337 "height=" 337 "width=" 615 "border=" 0 "/>
PS: Note that the terminal's top path has changed.
3. Restart the terminal to see if it takes effect.
4. Go back to the value in the PS1 above and turn it into:
< p>if ["$color _prompt" = yes]; Then ps1= ' ${debian_chroot:+ ($debian _chroot)}\[\033[01;32m\]\[email protected]\h\[\ 033[00m\]:\[\033[01;34m\]\ w \[\ 033[00m\]\$ ' Else ps1= ' ${debian_chroot:+ ($debian _chroot)}\[email protected]\h:\ w \$ ' Fi unset color_prompt Force_color_prompt # If This is a xterm set the title to [email protected]:d ir case ' $TERM ' in Xterm*|rx vt*) ps1= "\[\e]0;${debian_chroot:+ ($debian _chroot)}\[email protected]\h: \ Span style= "color: #0000ff;" >w \a\] $PS 1″ ;; *) ;; Esac |
Then save and exit Vim, and then source:
The effect is as follows:
650) this.width=650; "Title=" Now prompt also show short path "style=" Border-top:0px;border-right:0px;background-image: none;border-bottom:0px;padding-top:0px;padding-left:0px;border-left:0px;padding-right:0px; "alt=" Now prompt Also Show short path "src=" Http://i2.wp.com/www.crifan.com/files/pic/uploads/2013/08/now-prompt-also-show-short-path_ thumb.png?resize=615%2c125 "height=" width= "615" border= "0"/>
Summary
To change the display of the absolute path in Ubuntu terminal to the current path (folder), you need to modify your. BASHRC, and change the lowercase w to uppercase W:
(1) title for terminal
From:
12345678 |
# If this is an xterm set the title to [email protected]:dir case "$TERM" in xterm*|rxvt*) PS1= "\[\e]0;${debian_chroot:+($debian_chroot)}\[email protected]\h: \w\a\]$PS1" ;; *) ;; esac |
Switch
12345678 |
# If this is an xterm set the title to [email protected]:dir case "$TERM" in xterm*|rxvt*) PS1= "\[\e]0;${debian_chroot:+($debian_chroot)}\[email protected]\h: \W\a\]$PS1" ;; *) ;; esac |
(2) Current display prompt for the terminal
From:
?
123456 |
if [
"$color_prompt" =
yes ];
then
PS1=
‘${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ‘
else
PS1=
‘${debian_chroot:+($debian_chroot)}\[email protected]\h:\w\$ ‘
fi
unset color_prompt force_color_prompt
|
Switch
?
123456 |
if [
"$color_prompt" =
yes ];
then
PS1=
‘${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[email protected]\h\[\033[00m\]:\[\033[01;34m\]\W\[\033[00m\]\$ ‘
else
PS1=
‘${debian_chroot:+($debian_chroot)}\[email protected]\h:\W\$ ‘
fi
unset color_prompt force_color_prompt
|
This article is from "Narcissus" blog, please make sure to keep this source http://10704527.blog.51cto.com/10694527/1795148
Only the current path is displayed under the Ubantu terminal and the absolute path is not displayed