Skip to content

Powerline 사용

Windows Terminal에 WSL용 Powerline 설정하기

  • 생성일: 2020년 9월 2일 오후 7:17
  • 업데이트됨: 2020년 9월 2일 오후 7:42

Powerline을 이용해 WSL 터미널을 좀 더 알아보기 쉽도록 꾸미고자 한다.

WSL에서 다음과 같이 powerline-go를 설치한다.

sudo apt install golang-go
go get -u github.com/justjanne/powerline-go

Ubuntu 프로프트를 변경한다.

nano ~/.bashrc

아래 내용을 추가한다.

GOPATH=$HOME/go
function _update_ps1() {
    PS1="$($GOPATH/bin/powerline-go -condensed -newline -error $?)"
}
if [ "$TERM" != "linux" ] && [ -f "$GOPATH/bin/powerline-go" ]; then
    PROMPT_COMMAND="_update_ps1; $PROMPT_COMMAND"
fi

-condensed : 불필요한 띄어쓰기를 없앤다.

-newline : 다음 줄에 프로프트를 표시한다.

Font는 powerline-fonts 중에서 "Ubuntu Mono derivative Powerline" 를 사용했고 font 설정은 아래와 같이 한다.

mkdir ~/.fonts
copy Ubuntu* ~/.fonts
fc-cache -f -v

fc-cache명령으로 새 폰트를 추가한다.

Windows Terminal의 경우 아래와 같이 설정했다.

{

    "$schema": "https://aka.ms/terminal-profiles-schema",

    "defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
    "copyOnSelect": false,
    "copyFormatting": false,
    "profiles":
    {
        "defaults":
        {
            "fontFace": "Ubuntu Mono derivative Powerline",
            "fontSize": 11,
            "fontWeight": "thin",
            "useAcrylic": false,
        },
        "list":
        [
            {
                "guid": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
                "name": "Windows PowerShell",
                "commandline": "pwsh.exe",
                "hidden": false
            },
            {
                "guid": "{0caa0dad-35be-5f56-a8ff-afceeeaa6101}",
                "name": "명령 프롬프트",
                "commandline": "cmd.exe",
                "hidden": false
            },
            {
                "guid": "{c6eaf9f4-32a7-5fdc-b5cf-066e8a4b1e40}",
                "hidden": false,
                "name": "Ubuntu-18.04",
                "source": "Windows.Terminal.Wsl",
                "backgroundImage": "C:/Users/..../Pictures/protect/ubuntu-18.04-default-wallpaper-2.jpg",
                "backgroundImageOpacity": 0.2,
                "backgroundImageAlignment": "top",
                "backgroundImageStretchMode": "fill"
            },
            {
                "guid": "{b453ae62-4e3d-5e58-b989-0a998ec441b8}",
                "hidden": false,
                "name": "Azure Cloud Shell",
                "source": "Windows.Terminal.Azure"
            },
            {
                "guid": "{574e775e-4f2a-5b96-ac1e-a2962a402336}",
                "hidden": false,
                "name": "PowerShell",
                "source": "Windows.Terminal.PowershellCore"
            }
        ]
    },
    "schemes": [],
    "keybindings":
    [
        { "command": {"action": "copy", "singleLine": false }, "keys": "ctrl+c" },
        { "command": "paste", "keys": "ctrl+v" },
        { "command": "find", "keys": "ctrl+shift+f" },

        // Press Alt+Shift+D to open a new pane.
        // - "split": "auto" makes this pane open in the direction that provides the most surface area.
        // - "splitMode": "duplicate" makes the new pane use the focused pane's profile.
        // To learn more about panes, visit https://aka.ms/terminal-panes
        { "command": { "action": "splitPane", "split": "auto", "splitMode": "duplicate" }, "keys": "alt+shift+d" }
    ]
}

댓글