git 설치 시 딸려오는 git bash는 윈도우 terminal에서는 제공되지 않는 Unix 명령어들이 다수 포함되어 있어서 매우 편리하다. 나도 현재 VScode 기본 터미널로 Git Bash 쉘을 쓰고 있고.

 

하지만, man 명령어가 없다는게 아쉬워서 이걸 추가할 수 있는 방법이 없을지 찾아봤다.

 

https://github.com/swcarpentry/shell-novice/issues/249

 

man command not found on git bash · Issue #249 · swcarpentry/shell-novice

man doesn't seem to be installed on git bash - learners get a "man: command not found" error when they try to use it.

github.com

 

보니까 .bash_profile에 man(){ $1 --help }을 추가하라는 사람도 있고 (링크),

.bashrc를 수정하라는 사람도 있었다 (링크)

 

 

🤔 .bashrc? .bash_profile?

핀토스 할때도 .bashrc 를 수정한 적이 있었는데, 이게 뭐하는 녀석인지 제대로 알아보지 않은 것 같다.

 

👏 여러 링크를 찾아봤는데, 'bash-startup-file' 이라는 말로 요약할 수 있을 것 같다.

쉘을 처음 켰을 때 .bashrc 혹은 .bash_profile이 실행된다는 것.

쉘이 Login Shell 이면 .bash_profile이, Non-Login Shell 이면 .bashrc가 실행된다고 한다.

https://linuxize.com/post/bashrc-vs-bash-profile/#bash-startup-files

https://jongmin92.github.io/2016/12/13/Linux%20&%20Ubuntu/bashrc-bash_profile/

https://dohk.tistory.com/191

 


두번째 링크를 통해서 Git bash에 man 명령어를 추가할 수 있었다. (정확히 말하자면, man을 기존의 --help 명령어에 대한 alias로 만든 것)

 

bash의 root 폴더 (ls -a ~ | grep bash) 를 보니까, .bashrc나 .bash_profile같은 파일이 없더라.

아무래도 Git bash는 로그인 없이 사용하는 쉘이니, .bashrc 파일을 만들고 아래 쉘 스크립트를 복붙했다.

myMan(){
        $1 --help | less
}

# if man command not found, alias to myMan
man 2>/dev/null
if [ $? -eq 127 ]
then
        alias man=myMan
fi

이제 man node 치면 매뉴얼이 뜬다! 😃

 

추가)

\dev\null (공부할만한 블로그 링크)

이라던가

쉘 스크립트에 대해선 더 공부가 필요할 것 같다!

 

 

/etc/profile, ~/.bash_profile, ~/.bashrc, /etc/bashrc 파일 비교

https://coding-chobo.tistory.com/72?category=876096

+ Recent posts