Mac 터미널(예: Linux 터미널)에 항상 전체 디렉터리 경로를 표시하는 방법

Mac 터미널(예: Linux 터미널)에 항상 전체 디렉터리 경로를 표시하는 방법

내 우분투 터미널에는 항상 현재 디렉토리가 완전히 표시되어 있습니다. 다음과 같습니다:

blabla@blulu:~/music/my_album/classical/beethoven$

하지만 내 Mac(Mac OS X 10.6.5) 터미널에서는 전체 경로가 표시되지 않으며 다음과 같습니다.

blabas-MacBook-Pro:클래식 베토벤$

어쨌든 Mac 터미널 동작을 Linux 터미널처럼 작동하도록 변경할 수 있습니까?

답변1

Bash가 "user@hostname:path/to/directory$"를 프롬프트로 반환하도록 하려면 ~/.bash_profile에 다음 줄을 추가하세요.

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

또는

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

$와 명령 사이에 공백을 두는 것을 좋아한다면

변경 사항을 즉시 적용하려면 열려 있는 모든 창에서 다음 명령을 실행하십시오(또는 터미널을 다시 시작하십시오).

source ~/.bash_profile

편집하다: 사용 가능한 문자열 목록은 bash( man bash) 매뉴얼 페이지의 "PROMPTING" 단락에서 찾을 수 있습니다.

격려

  When executing interactively, bash displays the primary prompt PS1 when it is ready to read a command, and the secondary prompt PS2 when it needs more input to complete a command.  Bash allows these prompt strings  to  be  customized  by
   inserting a number of backslash-escaped special characters that are decoded as follows:
          \a     an ASCII bell character (07)
          \d     the date in "Weekday Month Date" format (e.g., "Tue May 26")
          \D{format}
                 the format is passed to strftime(3) and the result is inserted into the prompt string; an empty format results in a locale-specific time representation.  The braces are required
          \e     an ASCII escape character (033)
          \h     the hostname up to the first `.'
          \H     the hostname
          \j     the number of jobs currently managed by the shell
          \l     the basename of the shell's terminal device name
          \n     newline
          \r     carriage return
          \s     the name of the shell, the basename of $0 (the portion following the final slash)
          \t     the current time in 24-hour HH:MM:SS format
          \T     the current time in 12-hour HH:MM:SS format
          \@     the current time in 12-hour am/pm format
          \A     the current time in 24-hour HH:MM format
          \u     the username of the current user
          \v     the version of bash (e.g., 2.00)
          \V     the release of bash, version + patch level (e.g., 2.00.0)
          \w     the current working directory, with $HOME abbreviated with a tilde
          \W     the basename of the current working directory, with $HOME abbreviated with a tilde
          \!     the history number of this command
          \#     the command number of this command
          \$     if the effective UID is 0, a #, otherwise a $
          \nnn   the character corresponding to the octal number nnn
          \\     a backslash
          \[     begin a sequence of non-printing characters, which could be used to embed a terminal control sequence into the prompt
          \]     end a sequence of non-printing characters

답변2

내 Mac의 centOS 터미널과 매우 유사하게 보이도록 만들었습니다. 터미널에서 bash_profile 열기

nano ~/.bash_profile

다음을 추가하세요

# Show always fullpath on terminal
export PS1='\u@\H [\w]$ '

터미널을 다시 시작하면 다음과 같이 표시됩니다.

[email protected] [/Applications/MAMP/htdocs]$ 

답변3

Mac에 대해서는 잘 모르겠지만 Ubuntu에서는Gnome 터미널 프롬프트를 변경했습니다.~와 함께

PS1="\a\n\n\e[31;1m\u@\h on \d at \@\n\e[33;1m\w\e[0m\n$ "

답변4

편집하고 싶지 않다면 ~/.bash_profile터미널 프로필을 구성하면 됩니다. 을 클릭 Terminal > Prefences하고 거기에서 Profiles탭으로 이동한 다음 Shell탭으로 이동합니다. 활성화 [x] Run command하고 입력합니다 export PS1='\u@\H:\w$ '.

그것은 그것을 수행하는 또 다른 방법일 뿐입니다.

여기에 이미지 설명을 입력하세요

관련 정보