Toggle theme
문제를 잘 정의하는 것은 문제를 절반 해결한 것이다. - 2023.12
사용자 도구
Toggle theme
로그인
사이트 도구
검색
도구
문서 보기
이전 판
PDF로 내보내기
Fold/unfold all
역링크
최근 바뀜
미디어 관리자
사이트맵
로그인
>
최근 바뀜
미디어 관리자
사이트맵
현재 위치:
start
»
wiki
»
os
»
linux
»
bashrc
wiki:os:linux:bashrc
이 문서는 읽기 전용입니다. 원본을 볼 수는 있지만 바꿀 수는 없습니다. 문제가 있다고 생각하면 관리자에게 문의하세요.
====== bashrc 커스터마이징 ====== <WRAP left notice 80%> * description : bashrc 유용한 정보 모음 * author : 주레피 * email : dhan@repia.com * lastupdate : 2020-01-31 </WRAP> <WRAP clear/> ===== Environment(환경변수) ===== <code bash> # date 관련 D_YMD=`date +%Y%m%d` D_Y-M-D=`date +%Y-%m-%d` # TMOUT=0 export TMOUT D_YMD D_Y-M-D </code> > export를 사용하면 하위 프로세스까지 환경변수가 상속됨 > date와 같이 실행된 결과를 Value로 받을 때는 ` <- 탭위의 기호 임에 주의하자!! ===== Alias ===== ~/.bashrc 파일에 내용 추가 <code bash> # 검색엔진 관련 2020-02-10, Repia RSA_ROOT='/data/app/RSA' alias rlog='tail -n200 -f ${RSA_ROOT}/logs/javaLog/log_${D_YMD}.txt' alias tlog='tail -n200 -f ${TOMCAT_ROOT}/logs/localhost.${D_Y-M-D}.log' alias search='cd ${RSA_ROOT}' alias sbin='cd ${RSA_ROOT}/bin' alias slog='cd ${RSA_ROOT}/logs' alias sfront='cd ${RSA_ROOT}/bin/html' export RSA_ROOT </code> >#으로 시작하면 주석으로 인식 <WRAP clear /> 적용 방법 파일을 수정한 후 적용하기 위해서는 로그아웃을 하고 다시 로그인을 해야 하지만, 아래와 같이 실행하면 현재의 Shell에서도 적용된다. <code bash> $> source ~/.bashrc or $> . ~/.bashrc </code> alias 명령어 <code bash> [www@dev tmp]$ alias alias egrep='egrep --color=auto' alias fgrep='fgrep --color=auto' alias grep='grep --color=auto' alias l.='ls -d .* --color=auto' alias ll='ls -l --color=auto' alias ls='ls --color=auto' alias vi='vim' alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde' [www@dev heqms.repia.com]$ </code> > 이전에 설정된 내용 확인 가능 ===== Example ===== <code bash> # .bashrc # User specific aliases and functions alias rm='rm -i' alias cp='cp -i' alias mv='mv -i' # Source global definitions if [ -f /etc/bashrc ]; then . /etc/bashrc fi </code> Git 브랜치 칼라로 보여주기 <code bash> parse_git_branch() { git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' } if [ "$color_prompt" = yes ]; then PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\] $(parse_git_branch)\[\033[00m\]\$ ' else PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' fi # THE SIX LINES BELOW are the default prompt and the unset (which were in the original .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 #unset color_prompt force_color_prompt </code> ===== Ref ===== * [[https://askubuntu.com/questions/730754/how-do-i-show-the-git-branch-with-colours-in-bash-prompt|How do I show the git branch with colours in Bash prompt?]] ---- {{tag>주레피 bash bashrc}}
/volume1/web/dokuwiki/data/pages/wiki/os/linux/bashrc.txt
· 마지막으로 수정됨: 2023/01/13 18:44 (바깥 편집)
문서 도구
문서 보기
이전 판
역링크
PDF로 내보내기
Fold/unfold all
맨 위로