用户配置

配置文件的默认路径:

  • Linux:~/.config/lazygit/config.yml
  • MacOS:~/Library/Application Supp或t/lazygit/config.yml
  • 窗口:%APPDATA%\lazygit\config.yml

对于旧安装(有点尴尬:我当时没有意识到你不需要为路径提供供应商名称,所以我只使用了我的名称):

  • Linux:~/.config/jesseduffield/lazygit/config.yml
  • MacOS:~/Library/Application Support/jesseduffield/lazygit/config.yml
  • 窗口:%APPDATA%\jesseduffield\lazygit\config.yml

默认

gui:
  # stuff relating to the UI
  scrollHeight: 2 # how many lines you scroll by
  scrollPastBottom: true # enable scrolling past the bottom
  sidePanelWidth: 0.3333 # number from 0 to 1
  expandFocusedSidePanel: false
  mainPanelSplitMode: 'flexible' # one of 'horizontal' | 'flexible' | 'vertical'
  language: 'auto' # one of 'auto' | 'en' | 'zh' | 'pl' | 'nl'
  theme:
    lightTheme: false # For terminals with a light background
    activeBorderColor:
      - white
      - bold
    inactiveBorderColor:
      - green
    optionsTextColor:
      - blue
    selectedLineBgColor:
      - default
    selectedRangeBgColor:
      - blue
    cherryPickedCommitBgColor:
      - blue
    cherryPickedCommitFgColor:
      - cyan
  commitLength:
    show: true
  mouseEvents: true
  skipUnstageLineWarning: false
  skipStashWarning: true
  showFileTree: true # for rendering changes files in a tree format
  showListFooter: true # for seeing the '5 of 20' message in list panels
  showRandomTip: true
  showCommandLog: true
  commandLogSize: 8
  authorColors: # in case you're not happy with the randomly assigned colour
    'John Smith': '#ff0000'
git:
  paging:
    colorArg: always
    useConfig: false
  merging:
    # only applicable to unix users
    manualCommit: false
    # extra args passed to `git merge`, e.g. --no-ff
    args: ''
  log:
    # one of date-order, author-date-order, topo-order.
    # topo-order makes it easier to read the git log graph, but commits may not
    # appear chronologically. See https://git-scm.com/docs/git-log#_commit_ordering
    order: 'topo-order'
    # one of always, never, when-maximised
    # this determines whether the git graph is rendered in the commits panel
    showGraph: 'when-maximised'
  skipHookPrefix: WIP
  autoFetch: true
  branchLogCmd: 'git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium {{branchName}} --'
  allBranchesLogCmd: 'git log --graph --all --color=always --abbrev-commit --decorate --date=relative  --pretty=medium'
  overrideGpg: false # prevents lazygit from spawning a separate process when using GPG
  disableForcePushing: false
  parseEmoji: false
  diffContextSize: 3 # how many lines of context are shown around a change in diffs
os:
  editCommand: '' # see 'Configuring File Editing' section
  editCommandTemplate: '{{editor}} {{filename}}'
  openCommand: ''
refresher:
  refreshInterval: 10 # file/submodule refresh interval in seconds
  fetchInterval: 60 # re-fetch interval in seconds
update:
  method: prompt # can be: prompt | background | never
  days: 14 # how often an update is checked for
reporting: 'undetermined' # one of: 'on' | 'off' | 'undetermined'
confirmOnQuit: false
# determines whether hitting 'esc' will quit the application when there is nothing to cancel/close
quitOnTopLevelReturn: false
disableStartupPopups: false
notARepository: 'prompt' # one of: 'prompt' | 'create' | 'skip'
keybinding:
  universal:
    quit: 'q'
    quit-alt1: '<c-c>' # alternative/alias of quit
    return: '<esc>' # return to previous menu, will quit if there's nowhere to return
    quitWithoutChangingDirectory: 'Q'
    togglePanel: '<tab>' # goto the next panel
    prevItem: '<up>' # go one line up
    nextItem: '<down>' # go one line down
    prevItem-alt: 'k' # go one line up
    nextItem-alt: 'j' # go one line down
    prevPage: ',' # go to next page in list
    nextPage: '.' # go to previous page in list
    gotoTop: '<' # go to top of list
    gotoBottom: '>' # go to bottom of list
    scrollLeft: 'H' # scroll left within list view
    scrollRight: 'L' # scroll right within list view
    prevBlock: '<left>' # goto the previous block / panel
    nextBlock: '<right>' # goto the next block / panel
    prevBlock-alt: 'h' # goto the previous block / panel
    nextBlock-alt: 'l' # goto the next block / panel
    jumpToBlock: ['1', '2', '3', '4', '5'] # goto the Nth block / panel
    nextMatch: 'n'
    prevMatch: 'N'
    optionMenu: 'x' # show help menu
    optionMenu-alt1: '?' # show help menu
    select: '<space>'
    goInto: '<enter>'
    openRecentRepos: '<c-r>'
    confirm: '<enter>'
    confirm-alt1: 'y'
    remove: 'd'
    new: 'n'
    edit: 'e'
    openFile: 'o'
    scrollUpMain: '<pgup>' # main panel scroll up
    scrollDownMain: '<pgdown>' # main panel scroll down
    scrollUpMain-alt1: 'K' # main panel scroll up
    scrollDownMain-alt1: 'J' # main panel scroll down
    scrollUpMain-alt2: '<c-u>' # main panel scroll up
    scrollDownMain-alt2: '<c-d>' # main panel scroll down
    executeCustomCommand: ':'
    createRebaseOptionsMenu: 'm'
    pushFiles: 'P'
    pullFiles: 'p'
    refresh: 'R'
    createPatchOptionsMenu: '<c-p>'
    nextTab: ']'
    prevTab: '['
    nextScreenMode: '+'
    prevScreenMode: '_'
    undo: 'z'
    redo: '<c-z>'
    filteringMenu: '<c-s>'
    diffingMenu: 'W'
    diffingMenu-alt: '<c-e>' # deprecated
    copyToClipboard: '<c-o>'
    submitEditorText: '<enter>'
    appendNewline: '<a-enter>'
    extrasMenu: '@'
    toggleWhitespaceInDiffView: '<c-w>'
    increaseContextInDiffView: '}'
    decreaseContextInDiffView: '{'
  status:
    checkForUpdate: 'u'
    recentRepos: '<enter>'
  files:
    commitChanges: 'c'
    commitChangesWithoutHook: 'w' # commit changes without pre-commit hook
    amendLastCommit: 'A'
    commitChangesWithEditor: 'C'
    ignoreFile: 'i'
    refreshFiles: 'r'
    stashAllChanges: 's'
    viewStashOptions: 'S'
    toggleStagedAll: 'a' # stage/unstage all
    viewResetOptions: 'D'
    fetch: 'f'
    toggleTreeView: '`'
  branches:
    createPullRequest: 'o'
    viewPullRequestOptions: 'O'
    checkoutBranchByName: 'c'
    forceCheckoutBranch: 'F'
    rebaseBranch: 'r'
    mergeIntoCurrentBranch: 'M'
    viewGitFlowOptions: 'i'
    fastForward: 'f' # fast-forward this branch from its upstream
    pushTag: 'P'
    setUpstream: 'u' # set as upstream of checked-out branch
    fetchRemote: 'f'
  commits:
    squashDown: 's'
    renameCommit: 'r'
    renameCommitWithEditor: 'R'
    viewResetOptions: 'g'
    markCommitAsFixup: 'f'
    createFixupCommit: 'F' # create fixup commit for this commit
    squashAboveCommits: 'S'
    moveDownCommit: '<c-j>' # move commit down one
    moveUpCommit: '<c-k>' # move commit up one
    amendToCommit: 'A'
    pickCommit: 'p' # pick commit (when mid-rebase)
    revertCommit: 't'
    cherryPickCopy: 'c'
    cherryPickCopyRange: 'C'
    pasteCommits: 'v'
    tagCommit: 'T'
    checkoutCommit: '<space>'
    resetCherryPick: '<c-R>'
    copyCommitMessageToClipboard: '<c-y>'
    openLogMenu: '<c-l>'
  stash:
    popStash: 'g'
  commitFiles:
    checkoutCommitFile: 'c'
  main:
    toggleDragSelect: 'v'
    toggleDragSelect-alt: 'V'
    toggleSelectHunk: 'a'
    pickBothHunks: 'b'
  submodules:
    init: 'i'
    update: 'u'
    bulkMenu: 'b'

平台默认值

Windows

os:
  openCommand: 'start "" {{filename}}'

Linux

os:
  openCommand: 'xdg-open {{filename}} >/dev/null'

OSX

os:
  openCommand: 'open {{filename}}'

配置文件编辑

Lazygit 将使用以下第一个集合编辑器编辑文件:

  1. config.yaml
os:
  editCommand: 'vim' # as an example
  1. $(git config core.editor)
  2. $GIT_EDITOR
  3. $VISUAL
  4. $EDITOR
  5. $(which vi)

如果没有设置这些选项,Lazygit 将记录一个错误。

可以在逐行模式下指定当前所在的行号。

os:
  editCommand: 'vim'
  editCommandTemplate: '{{editor}} +{{line}} {{filename}}'

or

os:
  editCommand: 'code'
  editCommandTemplate: '{{editor}} --goto {{filename}}:{{line}}'

editCommandTemplate 中的 {{editor}} 替换为 editCommand 的值。

覆盖默认配置文件位置

要覆盖默认配置目录,请使用 $CONFIG_DIR="~/.config/lazygit"。此目录包含配置文件以及 lazygit 用于跟踪会话状态的其他一些文件。

要覆盖使用的单个配置文件,请使用参数或环境变量。

如果要将特定的配置文件合并到更通用的配置文件中,可能是为了设置某些特定于主题的选项,可以提供逗号分隔的配置文件路径列表,如下所示:

lazygit --use-config-file=~/.base_lg_conf,~/.light_theme_lg_conf
or
LG_CONFIG_FILE="~/.base_lg_conf,~/.light_theme_lg_conf" lazygit

建议的配置值

适用于 VSCode 的用户

os:
  openCommand: 'code -rg {{filename}}'

颜色属性

对于颜色属性,可以选择属性数组(最多一个颜色属性),可用属性包括:

**颜色

  • 黑色
  • 红色
  • 绿色
  • 黄的
  • 蓝色
  • 洋红
  • 青色
  • 白色
  • “#ff00ff”

**修饰语

  • 大胆的
  • 违约
  • 反向 # 用于高对比度
  • 强调

灯光终端主题

如果无法阅读 / 查看文本的灯光终端主题存在问题,请添加这些设置

gui:
  theme:
    lightTheme: true
    activeBorderColor:
      - black
      - bold
    inactiveBorderColor:
      - black
    selectedLineBgColor:
      - default

努力查看所选行

如果你很难看到所选行,我建议在所选行上使用“反转”属性,如下所示:

gui:
  theme:
    selectedLineBgColor:
      - reverse
    selectedRangeBgColor:
      - reverse

以下内容也适用于一些人:

gui:
  theme:
    activeBorderColor:
      - white
      - bold
    inactiveBorderColor:
      - white
    selectedLineBgColor:
      - reverse
      - blue

或者,你可以在终端中禁用粗体字体,在这种情况下,启用粗体字体可以解决问题。

如果你仍然有问题,请提出问题。

示例着色

边界示例

键绑定

对于所有可能的键绑定选项,请选中 自定义键绑定。医学博士

Colemak 用户的密钥绑定示例

keybinding:
  universal:
    prevItem-alt: 'u'
    nextItem-alt: 'e'
    prevBlock-alt: 'n'
    nextBlock-alt: 'i'
    nextMatch: '='
    prevMatch: '-'
    new: 'k'
    edit: 'o'
    openFile: 'O'
    scrollUpMain-alt1: 'U'
    scrollDownMain-alt1: 'E'
    scrollUpMain-alt2: '<c-u>'
    scrollDownMain-alt2: '<c-e>'
    undo: 'l'
    redo: '<c-r>'
    diffingMenu: 'M'
    filteringMenu: '<c-f>'
  files:
    ignoreFile: 'I'
  commits:
    moveDownCommit: '<c-e>'
    moveUpCommit: '<c-u>'
  branches:
    viewGitFlowOptions: 'I'
    setUpstream: 'U'

自定义拉取请求 URL

一些 git 提供程序设置(例如内部 GitLab)可以为 git 相关调用和 web 界面 /API 本身提供不同的 URL。为了处理这些请求,Lazygit 需要知道它需要在哪里创建 pull 请求。你可以使用以下语法在 config.yml 文件上执行此操作:

services:
  '<gitDomain>': '<provider>:<webDomain>'

哪里:

  • gitDomain 表示 git 本身使用的域(即克隆 URL 上的域),例如 git.work.com
  • providergithubbitbucketgitlab
  • webDomain 是 git 服务公开 web 界面和 API 的 URL,例如 gitservice.work.com

预定义的提交消息前缀

在某些命名模式用于分支和提交的情况下,该模式可用于使用从分支名称解析的前缀填充提交消息。

例子:

  • 分支机构名称:feature/AB-123
  • 提交消息:[AB-123]正在添加功能
git:
  commitPrefixes:
    my_project: # This is repository folder name
      pattern: "^\\w+\\/(\\w+-\\w+).*"
      replace: '[$1] '

自定义 git 日志命令

你可以覆盖用于呈现所选分支日志的 git log 命令,如下所示:

git:
  branchLogCmd: "git log --graph --color=always --abbrev-commit --decorate --date=relative --pretty=medium --oneline {{branchName}} --"

结果:

不在存储库中启动

默认情况下,从非存储库的目录启动 lazygit 时,系统会提示你选择是否要初始化 repo。你可以在配置中使用以下选项之一覆盖此行为:

# for default prompting behaviour
notARepository: 'prompt'
# to skip and initialize a new repo
notARepository: 'create'
# to skip without creating a new repo
notARepository: 'skip'