Tag Archives: Korn Shell

Shells, 현재 작업중인 디렉토리를 프롬프트에 표시하는 방법

KSH의 경우
사용자의 .profile 파일에 다음과 같이 입력하십시오.

PS1='${PWD##*/}/ > '   # For partial pathname in the prompt.
PS1='${PWD}/ > '       # For full pathname in the prompt.

CSH의 경우
.login 파일에 다음 중 한 가지를 입력하십시오.

# For hostname and full pathname in the prompt.
set prompt="`hostname`:$cwd % "
alias cd 'cd \!*;set prompt="`hostname`:$cwd % "'

또는
# For just the full pathname in the prompt.
set prompt="$cwd % "
alias cd 'cd \!*;set prompt="$cwd % "'

또는
# For hostname and partial pathname in the prompt.
set prompt="`hostname`:`basename ${cwd}` % "
alias cd 'cd \!*;set prompt="`hostname`:`basename ${cwd}` % "'

또는
# For just the partial pathname in the prompt.
set prompt="`basename ${cwd}` % "
alias cd 'cd \!*;set prompt="`basename ${cwd}` % "'

BOURNE 쉘의 경우
Bourne 쉘(/bin/sh)에서 pwd로 변경하는 것처럼 PS1 프롬프트에서 변경하려면 계정의 .profile에 cd라는 새 함수를 생성하십시오.

cd() { chdir $* ; PS1="`pwd` $ "; }

이 cd 함수가 쉘에 내장된 cd 명령 대신 실행됩니다.

제품 영역: 유틸리티
제품: 쉘 스크립트
SUNOS 릴리즈: 모든 릴리즈
하드웨어: 모든 하드웨어

원문 출처
SUN Microsystems 기술 문서 OS