๐Ÿ”จGit Bash ์กฐ์ •๐Ÿ–Œ๏ธ

7469 ๋‹จ์–ด gitbashterminalshell
์—ฌ๊ธฐ์š”! ๐Ÿ‘‹

์˜ค๋Š˜ ์ €๋Š” Windows ํ„ฐ๋ฏธ๋„์—์„œ ์‚ฌ์šฉํ•˜๋Š” Git Bash๋ฅผ ๋ฏธ์„ธ ์กฐ์ •ํ•˜๊ณ  ์žˆ์—ˆ๊ธฐ ๋•Œ๋ฌธ์— ๋ˆ„๊ตฐ๊ฐ€ ์œ ์šฉํ•˜๋‹ค๊ณ  ์ƒ๊ฐํ•˜๋Š” ๊ฒฝ์šฐ๋ฅผ ๋Œ€๋น„ํ•˜์—ฌ ์—ฌ๊ธฐ์— ๋‹จ๊ณ„๋ฅผ ๋‚จ๊ฒจ๋‘๊ธฐ๋กœ ๊ฒฐ์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

์„ค์น˜



์ž, ๋จผ์ € Git ๋ฐ Windows Terminal ์„ ๋ชจ๋‘ ์„ค์น˜ํ•ฉ๋‹ˆ๋‹ค.

Windows ํ„ฐ๋ฏธ๋„์— Git-Bash ์ถ”๊ฐ€


  • Windows ํ„ฐ๋ฏธ๋„์—์„œ ์„ค์ •์„ ์—ฝ๋‹ˆ๋‹ค.
  • Guid ์ƒ์„ฑ: PowerShell์—์„œ [guid]::NewGuid()๋ฅผ ์ž…๋ ฅํ•˜์—ฌ ์ƒˆ Guid๋ฅผ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.
  • ์ƒˆ Git-Bash ํ”„๋กœํ•„์„ ์‚ฝ์ž…ํ•ฉ๋‹ˆ๋‹ค.

  •     {
            // Git Bash
            "guid": "{YOUR GUID}",
            "closeOnExit" : "always",
            "commandline" : 
            "\"%PROGRAMFILES%\\git\\usr\\bin\\bash.exe\" -i -l",
            "icon" : "C:\\Program 
            Files\\Git\\mingw64\\share\\git\\git-for-windows.ico",
            "name" : "Git Bash",
            "startingDirectory" : "%USERPROFILE%",
            "colorScheme": "Dracula"
        },
    


    Windows ํ„ฐ๋ฏธ๋„์—์„œ Git Bash ๋ฐฑ์ŠคํŽ˜์ด์Šค ํ‘œ์‹œ๋“ฑ ๊นœ๋ฐ•์ž„ ์ œ๊ฑฐ




    ๋นˆ ์ค„์—์„œ ๋ฐฑ์ŠคํŽ˜์ด์Šค ํ‚ค๋ฅผ ๋ˆ„๋ฅด๋ฉด Git Bash๊ฐ€ ์ž˜๋ชป ๊นœ๋ฐ•์ž…๋‹ˆ๋‹ค. ์ข€ ์งœ์ฆ๋‚˜๊ณ  ์ฝ”๋“œ ํ•œ ์ค„์ด๋ฉด ๊ณ ์น  ์ˆ˜ ์žˆ๋‹ค. ๋จผ์ € ์ง‘์— .inputrc ํŒŒ์ผ์„ ๋งŒ๋“ญ๋‹ˆ๋‹ค.

    code ~/.inputrc 
    


    VSCode๋ฅผ ์ข‹์•„ํ•˜๊ธฐ ๋•Œ๋ฌธ์— ์ฝ”๋“œ๋ฅผ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋ฅธ ํŽธ์ง‘๊ธฐ๋ฅผ ์‚ฌ์šฉํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋Ÿฐ ๋‹ค์Œ ์ด ํ…์ŠคํŠธ๋ฅผ ํŒŒ์ผ์— ์ถ”๊ฐ€ํ•˜๊ณ  ์ €์žฅํ•ฉ๋‹ˆ๋‹ค.

    set bell-style none
    


    ํ”„๋กฌํ”„ํŠธ ์Šคํƒ€์ผ ์ง€์ •



    ์ด๊ฒƒ์€ ์›๋ž˜ bash์ž…๋‹ˆ๋‹ค.

    ์˜ˆ, ์ €๋Š” ๋ฏธ๋‹ˆ๋ฉ€๋ฆฌ์ŠคํŠธ๋ฅผ ์ข‹์•„ํ•˜์ง€๋งŒ ์ œ๋ชฉ ํ‘œ์‹œ์ค„์„ ๋ณ€๊ฒฝํ•˜๊ณ  MYSYS๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  Git ์ €์žฅ์†Œ ์ƒํƒœ ๋ฐ ์‹œ๊ฐ„๊ณผ ๊ฐ™์€ ์ •๋ณด๋ฅผ ์ถ”๊ฐ€ํ•ด์•ผ ํ–ˆ์Šต๋‹ˆ๋‹ค.

    ์ด๋ฅผ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐฉ๋ฒ•์—๋Š” ์—ฌ๋Ÿฌ ๊ฐ€์ง€๊ฐ€ ์žˆ์Šต๋‹ˆ๋‹ค. ์ œ ์กฐ์–ธ์€ Git ํด๋”์—์„œ .git-prompt.sh๋ฅผ ๋ฎ์–ด์“ฐ๋Š” ๋Œ€์‹  ์ž์‹ ๋งŒ์˜ .bashrc๋ฅผ ์ƒ์„ฑํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค(Git ์—…๋ฐ์ดํŠธ๋ฅผ ๋ฎ์–ด์“ฐ๋ฉด ์‚ฌ์šฉ์ž ์ง€์ • ๋‚ด์šฉ์„ ์žƒ๊ฒŒ ๋ฉ๋‹ˆ๋‹ค...). ์ด์ œ ์ƒˆ .bashrc๋ฅผ ์ƒ์„ฑํ•˜์—ฌ ์‹œ์ž‘ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค. ๋‹ค์Œ ์ฝ”๋“œ๋ฅผ ์‹คํ–‰ํ•˜์—ฌ ์ƒ์„ฑํ•ฉ๋‹ˆ๋‹ค.

    code ~/.bashrc
    



    Git Bash๊ฐ€ ์ƒˆ .bash_profile ํŒŒ์ผ์„ ์ƒ์„ฑํ–ˆ๋‹ค๋Š” ๋ฉ”์‹œ์ง€๊ฐ€ ํ‘œ์‹œ๋ฉ๋‹ˆ๋‹ค. ๊ฑฑ์ •๋งˆ์„ธ์š”, ์ด์ •๋„๋ฉด ๊ดœ์ฐฎ์Šต๋‹ˆ๋‹ค. ์ด์ œ Git ํด๋”์— ์žˆ๋Š” git_prompt.sh ํŒŒ์ผ์˜ ์ „์ฒด ๋‚ด์šฉ์„ ์ƒˆ .bashrc์— ๋ณต์‚ฌํ•˜๊ณ  ํŽธ์ง‘ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

    ์ œ๋ชฉ ํ‘œ์‹œ์ค„ ๋ณ€๊ฒฝ



    ๊ฐ’์„ ๋ณ€๊ฒฝํ•ฉ๋‹ˆ๋‹ค.

    PS1='\[\033]0;TITTLE$PWD\007\]' # set window title
    


    MYSYS ์ œ๊ฑฐ



    ์ฝ”๋ฉ˜ํŠธ:

    #PS1="$PS1"'\[\033[35m\]'       # change to purple
    #PS1="$PS1"'$MSYSTEM '          # show MSYSTEM
    


    ํž˜๋‚ด ์ •๋ณด



    ์ด๊ฒƒ์„ ํŒŒ์ผ ๋์— ์ถ”๊ฐ€ํ•˜๋ฉด ' __git_ps1 '์ด ๋‚˜๋จธ์ง€ ์ž‘์—…์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

    #Git status options
    export GIT_PS1_SHOWSTASHSTATE=true
    export GIT_PS1_SHOWDIRTYSTATE=true
    export GIT_PS1_SHOWUNTRACKEDFILES=true
    export GIT_PS1_SHOWUPSTREAM="auto"
    


    ์‹œ๊ฐ„



    ์ด๊ฑฐ ์ถ”๊ฐ€ ํ•ด๋ด:

    PS1="$PS1"' \[\033[37m\][\A]'  # 24h time, white
    


    ๋ณ„์นญ



    ๋งˆ์ง€๋ง‰์œผ๋กœ ๋ณ„์นญ์€ ์–ด๋–ป์Šต๋‹ˆ๊นŒ? ํŒŒ์ผ์— ์ถ”๊ฐ€ํ•˜๊ธฐ๋งŒ ํ•˜๋ฉด ๋ฉ๋‹ˆ๋‹ค.

    #My aliases
    alias gs='git status -sb'
    alias gaa='git add --all'
    alias gc='git commit -m $2'
    alias gp='git push'
    alias gpo='git push origin'
    alias gpl='git pull'
    alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
    
    alias ls='ls -F --color=auto --show-control-chars'
    alias ll='ls -l'
    alias rm='rm -iv'
    


    ์š”์•ฝํ•˜๋ฉด ๋‹ค์Œ์€ ์ „์ฒด ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

    #My aliases
    alias gs='git status -sb'
    alias gaa='git add --all'
    alias gc='git commit -m $2'
    alias gp='git push'
    alias gpo='git push origin'
    alias gpl='git pull'
    alias gl="git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
    
    alias ls='ls -F --color=auto --show-control-chars'
    alias ll='ls -l'
    alias rm='rm -iv'
    
    # Prompt style
    if test -f /etc/profile.d/git-sdk.sh
    then
        TITLEPREFIX=SDK-${MSYSTEM#MINGW}
    else
        TITLEPREFIX=$MSYSTEM
    fi
    
    if test -f ~/.config/git/git-prompt.sh
    then
        . ~/.config/git/git-prompt.sh
    else
        PS1='\[\033]0;Git Bash$PWD\007\]' # set window title
        PS1="$PS1"'\n'                 # new line
        PS1="$PS1"'\[\033[32m\]'       # change to green
        PS1="$PS1"'\u@\h '             # user@host<space>
        #PS1="$PS1"'\[\033[35m\]'       # change to purple
        #PS1="$PS1"'$MSYSTEM '          # show MSYSTEM
        PS1="$PS1"'\[\033[33m\]'       # change to white
        PS1="$PS1"'\w'                 # current working directory
        if test -z "$WINELOADERNOEXEC"
        then
            GIT_EXEC_PATH="$(git --exec-path 2>/dev/null)"
            COMPLETION_PATH="${GIT_EXEC_PATH%/libexec/git-core}"
            COMPLETION_PATH="${COMPLETION_PATH%/lib/git-core}"
            COMPLETION_PATH="$COMPLETION_PATH/share/git/completion"
            if test -f "$COMPLETION_PATH/git-prompt.sh"
            then
                . "$COMPLETION_PATH/git-completion.bash"
                . "$COMPLETION_PATH/git-prompt.sh"
                PS1="$PS1"'\[\033[36m\]'  # change color to cyan
                PS1="$PS1"'`__git_ps1`'   # bash function
            fi
        fi
        PS1="$PS1"' \[\033[37m\][\A]'  # 24h time, white
        PS1="$PS1"'\[\033[0m\]'        # change color
        PS1="$PS1"'\n'                 # new line
        PS1="$PS1"'$ '                 # prompt: always $
    fi
    
    MSYS2_PS1="$PS1"               # for detection by MSYS2 SDK's bash.basrc
    
    # Evaluate all user-specific Bash completion scripts (if any)
    if test -z "$WINELOADERNOEXEC"
    then
        for c in "$HOME"/bash_completion.d/*.bash
        do
            # Handle absence of any scripts (or the folder) gracefully
            test ! -f "$c" ||
            . "$c"
        done
    fi
    
    #Git status options
    export GIT_PS1_SHOWSTASHSTATE=true
    export GIT_PS1_SHOWDIRTYSTATE=true
    export GIT_PS1_SHOWUNTRACKEDFILES=true
    export GIT_PS1_SHOWUPSTREAM="auto"
    
    


    ์•„์ฃผ ์ข‹์•„, ๋๋‚ฌ์–ด! ๋ชจ๋“  ๊ฒƒ์„ ์ €์žฅํ•˜๊ณ  ํ„ฐ๋ฏธ๋„์„ ๋‹ค์‹œ ์‹œ์ž‘ํ•˜๊ณ  ์ฆ๊ธฐ์‹ญ์‹œ์˜ค. ์ด๊ฒƒ์€ Git Bash์˜ ๋ชจ๋“  ๊ธฐ๋ณธ ์ •๋ณด๊ฐ€ ํฌํ•จ๋œ ๊นจ๋—ํ•œ bash์˜ ๊ฒฐ๊ณผ์ž…๋‹ˆ๋‹ค.



    ์ด๊ฒƒ์ด ๋ˆ„๊ตฐ๊ฐ€๋ฅผ ๋•๊ธฐ๋ฅผ ๋ฐ”๋ž๋‹ˆ๋‹ค. Google์—์„œ ์ฐพ๊ธฐ๊ฐ€ ์‰ฝ์ง€ ์•Š์Šต๋‹ˆ๋‹ค. ๊ฑด๋ฐฐ๐Ÿค˜

    ์ข‹์€ ์›นํŽ˜์ด์ง€ ์ฆ๊ฒจ์ฐพ๊ธฐ