IT

Mac에서 기본 셸을 설정하는 방법

lottoking 2020. 5. 27. 07:44
반응형

Mac에서 기본 셸을 설정하는 방법


터미널을 시작할 때마다 물고기를 다시 입력하는 것을 좋아하지 않습니다. fish기본적으로 사용 하고 싶습니다 . Mac에서 피쉬 쉘을 기본 쉘로 설정하려면 어떻게해야합니까?


이는 MacOS Sierra 10.12.5 (16F73) 및 기타 최신 및 향후 버전의 MacOS에 적용됩니다.

  1. chsh기본 쉘을 변경하기에 충분하지 않습니다. 터미널이 열려있는 동안 Command+ 를 누르고 ,'다음으로 쉘 열기'옵션을 '기본 로그인 쉘'로 변경하십시오.

  2. bash의 경우 echo $BASH_VERSION의도 한 bash 버전을 실행하고 있는지 확인 하기 위해 실행해야합니다 . bash --version정확한 정보를 제공하지 않습니다.


1. sudo nano / etc / shells 여기에 이미지 설명을 입력하십시오

2. 쉘 목록에 / usr / local / bin / fish를 추가하십시오. 여기에 이미지 설명을 입력하십시오

3. chsh -s / usr / local / bin / fish


chsh 를 사용하여 사용자의 쉘을 변경할 수 있습니다 .

예를 들어 다음 코드를 실행하여 쉘을 Zsh로 변경하십시오.

chsh -s /bin/zsh

맨 페이지 및 Lorin에서 설명한대로 OS에서 쉘을 알 수없는 경우 알려진 목록에 쉘을 추가해야합니다 /etc/shells.


터미널에서 :

  1. /etc/shells비밀번호 를 추가 하려면 관리자 비밀번호가 필요합니다.

    sudo echo /usr/local/bin/fish >> /etc/shells
    
  2. 다음을 사용하여 Fish를 기본 쉘로 만드십시오 chsh.

    chsh -s /usr/local/bin/fish
    

시스템 환경 설정에서 :

  1. 사용자 및 그룹 → 현재 사용자 → 고급 옵션 ...을 Ctrl- 클릭

  2. 로그인 쉘을 다음으로 변경하십시오. /usr/local/bin/fish

    로그인 쉘

  3. 확인을 누르고 로그 아웃 한 후 다시 로그인하십시오.


다른 방법은 다음과 같습니다.

MacPorts와 함께 설치했다고 가정하면 다음을 수행하여 수행 할 수 있습니다.

sudo port install fish

쉘은에 위치 /opt/local/bin/fish합니다.

OSX에 이것이 유효한 쉘임을 알려야합니다. 그렇게하려면 /etc/shells파일 끝에이 경로를 추가 하십시오.

Once you've done this, you can change the shell by going to System Preferences -> Accounts. Click on the Lock to allow changes. Right-click on the account, and choose "Advanced Options...". In the "Login shell" field, add the path to fish.


The only thing that worked for me was a combination of all these methods.

  1. First I had to add fish to the /etc/shells file

  2. Then I ran chsh -s /usr/local/bin/fish

  3. Finally, I typed Command+, and added /usr/local/bin/fish to the default path there

Only after I had done all three things did fish start popping up as the default for new terminal windows.


Mac OS X: How to change the Terminal shell


On macOS Mojave I had to do the following (using zsh as an example):

brew install zsh
sudo sh -c "echo $(which zsh) >> /etc/shells"
chsh -s $(which zsh)

  1. Open your terminal and press command+, (comma). This will open a preferences window.
  2. The first tab is 'General'.
  3. Find 'Shells open with' setting and choose 2nd option which needs complete path to the shell.
  4. Paste the link to your fish command, which generally is /usr/local/bin/fish.

I am using macOS Sierra.


the chsh program will let you change your default shell. It will want the full path to the executable, so if your shell is fish then it will want you to provide the output given when you type which fish.

You'll see a line starting with "Shell:". If you've never edited it, it most likely says "Shell: /bin/bash". Replace that /bin/bash path with the path to your desired shell.


When in the terminal, open the terminal preferences using Command+,.

On the Setting Tab, select one of the themes, and choose the shell tab on the right.

You can set the autostart command fish.


How to get the latest version of bash on modern macOS (tested on Mojave).

brew install bash
which bash | sudo tee -a /etc/shells
chsh -s $(which bash)

Then you are ready to get vim style tab completion which is only available on bash>=4 (current version in brew is 5.0.2

# If there are multiple matches for completion, Tab should cycle through them
bind 'TAB':menu-complete

# Display a list of the matching files
bind "set show-all-if-ambiguous on"

# Perform partial completion on the first Tab press,
# only start cycling full results on the second Tab press
bind "set menu-complete-display-prefix on"

heimdall:~ leeg$ dscl
Entering interactive mode... (type "help" for commands)
 > cd /Local/Default/Users/
/Local/Default/Users > read <<YOUR_USER>>
[...]
UserShell: /bin/bash
/Local/Default/Users >

just change that value (with the write command in dscl).


This work for me on fresh install of mac osx (sierra):

  1. Define current user as owner of shells
sudo chown $(whoami) /etc/shells
  1. Add Fish to /etc/shells
sudo echo /usr/local/bin/fish >> /etc/shells
  1. Make Fish your default shell with chsh
chsh -s /usr/local/bin/fish
  1. Redefine root as owner of shells
sudo chown root /etc/shells

In case you are having troubles with the other ways, worked on mac Mojave but should generally work.

which fish

"시스템 환경 설정> 사용자 및 그룹> 마우스 오른쪽 단추로 사용자, 고급 옵션"에 출력 경로를 추가하십시오. 결과를 "로그인 쉘"에 붙여 넣으십시오.

참고 URL : https://stackoverflow.com/questions/453236/how-to-set-my-default-shell-on-mac

반응형