[Tool] Cmder 設定

軟體:Cmder
https://github.com/z-Wind/cmder-setting

簡介:cmder 設定方法,取代 window cmd

# 資料夾為中文,git 後面無 master

暫無解,請先用英文命名資料夾

# cmder-setting

    1. 解決重覆字的問題(新版已解)
        setting -> Main -> Main console font -> Cancel Monospace

    2. 更改初始資料夾
        setting -> Startup -> Tasks -> {cmd}
        cmd /k "%ConEmuDir%\..\init.bat"  -new_console:d:"D:\HD\backup\Knowledge\GitHub"
        detail command in ConEmu document (-new_console)

    3. 加入環境變數 add cmder path to Enviroment variable Path
    4. ls命令中文路徑/文件名亂碼
        舊版:
        添加命令到cmder/config/aliases文件末尾…
        ls=ls --show-control-chars -F --color $*

        新版(v1.3.0):
        win+ctrl+p打開Settings
        在Settings > Startup > Environment裡添加:set LANG=zh_TW.UTF8
        然後重開
    5. 使用 portableGit
    修改 init.bat
    set GIT_INSTALL_ROOT=D:\pythonVenv\PortableGit
    set "PATH=%GIT_INSTALL_ROOT%\cmd;%PATH%"

    if defined GIT_INSTALL_ROOT (
        if exist "%GIT_INSTALL_ROOT%\cmd\git.exe" (goto :FOUND_GIT)
    )


# git-setting

    1. gitconfig
    [core]
        autocrlf = false # for window
        quotepath = false # 顯示 status 編碼
        #whitespace = cr-at-eol # ignore CR 忽略 window 特有的結尾
        #editor = notepad
    [gui]
        encoding = utf-8 # 圖形界面編碼
    [i18n]
        commitencoding = utf-8 # 提交信息編碼
        logoutputencoding = utf-8 # 輸出 log 編碼
    [push]
        # only pushes the current branch to the corresponding remote branch that 'git pull' uses to update the current branch.
        default = simple
   
    2.
    git config --global user.name "John Doe"
    git config --global user.email johndoe@example.com
   
    3. modify init.bat to change clink
    :: Run clink
@"%CMDER_ROOT%\vendor\clink_DEV\clink_x%architecture%.exe" inject --quiet --profile "%CMDER_ROOT%\config"
   
    4. gitattributes
    # 維持結尾,不更改
    # remain all file's line end LF = LF, CRLF = CRLF
    # * text auto change to
    * -text
   

# vim

    1. vimrc
    " display
    " fileencodings -> fileencoding -convert to-> encoding -> tenc
    " write
    " fileencodings -> fileencoding <-convert to- encoding <- tenc
   
   
    " Sets the character encoding for the file of this buffer.
    set fileencoding=utf-8
    " This is a list of character encodings considered when starting to edit an existing file.
    set fileencodings=ucs-bom,utf-8,big5,cp936,gb18030,euc-jp,euc-kr,latin1
    " Sets the character encoding used inside Vim.
    set encoding=utf8
    " Encoding used for the terminal
    set tenc=utf8
    " hotkey F12 to change display encoding
    map <F12> :set tenc=big5<cr>

git commit 亂碼
舊版搭配上方解法無問題
新版有問題,可能是 \usr\bin 中的 msysxxxx.dll 的某個有問題,因將舊版這部分貼過來會正常

# 程式無法執行

PATH 環境變數時最多只能讀取 2,048 字元,超出這個數字的字元全部都會被截斷
請檢查 使用者變數 & 系統變數 是否有重覆可移除的

# 畫面殘留文字

請編輯 Cmder 安裝目錄下的 vendor\init.bat 檔案
@prompt $E[1;32;40m$P$S{git}{hg}$S$_$E[1;30;40m{lamb}$S$E[0m
修改成以下即可:
@prompt $E[1;32;40m$P$S{git}{hg}$S$_$E[1;30;40m$$$S$E[0m

新版位置 vendor\clink.lua 檔案
更改掉 lambda λ 的值即可


# 關閉快捷鍵 Ctrl + W

因為 Cmder 預設將 Ctrl+W 設定為關閉目前主控台
但在 Linux 環境下 Ctrl+W 主要是用來刪除一段文字用的
設定 -> Keys & Macro -> 找到 Close active console 並把 hotkey 給清除掉即可

# 利用 bat 開啟 cmder 並執行指令

@echo off
SET CMDER_ROOT=D:\cmder
start %CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.exe /Icon "%CMDER_ROOT%\icons\cmder.ico" /Title Cmder /LoadCfgFile "%CMDER_ROOT%\vendor\conemu-maximus5\ConEmu.xml" -cmd cmd /k "%CMDER_ROOT%\vendor\init.bat && %~dp0Scripts\activate" -cur_console:d:"D:\initialFolder"

添加 cmder 到右鍵菜單

需在管理者權限下
加入 Cmder.exe /REGISTER ALL
移除 Cmder.exe /UNREGISTER ALL

參考

cmder中文顯示相關問題解決方案(1.3以上版本)

留言