5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

ターミナルの$の前(プロンプト)を短くする

Posted at

プロンプトは、変数PS1によって制御されているようなので、これを変更します。

変更前

~/.bashrc
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
Username@PCname:~/Documents/dir1/dir2$ 

ユーザー名を表示しない

~/.bashrc
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}@\h:\w\$ '
fi

編集後、source ~/.bashrc もしくはターミナル再起動

@PCname:~/Documents/dir1/dir2$ 

PC名を表示しない

~/.bashrc
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@:\[\033[01;34m\]\w\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@:\w\$ '
fi

編集後、source ~/.bashrc もしくはターミナル再起動

Username@:~/Documents/dir1/dir2$ 

カレントディレクトリを表示しない

~/.bashrc
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\u@\h:\$ '
fi

編集後、source ~/.bashrc もしくはターミナル再起動

Username@PCname:$ 

全部表示しない

~/.bashrc
if [ "$color_prompt" = yes ]; then
    PS1='${debian_chroot:+($debian_chroot)}\[\033[00m\]\$ '
else
    PS1='${debian_chroot:+($debian_chroot)}\$ '
fi

編集後、source ~/.bashrc もしくはターミナル再起動

$ 

参考

5
7
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
7

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?