Development/OS
Linux & Ubuntu Server 간단한 사용법 (프롬프트 변경하기) #12
evagrim
2022. 9. 25. 08:10
<프롬프트 변경하기> |
Linux(Unix)의 기본 프롬프트 설정은 작업하는 디렉토리가 깊어질수록
프롬프트 명령창의 길이가 달나라로 가버리기 때문에
사용자 프롬프트 창의 포맷을 변경을 하는 법을 알아두면 좋다
사용자 프롬프트 설정하기 |
현재 프롬프트 스트링(PS1) 출력하기 | |
username@username-server:~$ echo $PS1 | |
>> \[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\u@\h:\w\$ |
프롬프트 스트링(PS1) 변경하기 | |
username@username-server:~$ PS1="username : "; | |
username : ls | |
>> aa bb cc dd |
프롬프트 스트링의 이스케이프 문자 | |
\H | the hostname |
\h | the hostname up to the first '.' |
\d | the date |
\n | new line |
\r | carriage return |
\t | the current time in 24-hour |
\T | the current time in 12-hour |
참고 사이트 : https://tldp.org/HOWTO/Bash-Prompt-HOWTO/bash-prompt-escape-sequences.html |
주의) 프롬프트 변경 후 프로필에 저장하지 않을 경우 종료 후 재진입하면 프롬프트 기본설정으로 돌아온다