0
0
Просмотр исходного кода

feat(lazygit): add `lazygit` config

Joe 1 год назад
Родитель
Сommit
82fd34c6b9
4 измененных файлов с 143 добавлено и 0 удалено
  1. 1 0
      .config/.gitignore
  2. 5 0
      .config/lazygit/.gitignore
  3. 132 0
      .config/lazygit/config.yml
  4. 5 0
      .github/README.md

+ 1 - 0
.config/.gitignore

@@ -6,5 +6,6 @@
 !git/
 !jonathandarker/
 !lazydocker/
+!lazygit/
 !tmux/
 !zsh/

+ 5 - 0
.config/lazygit/.gitignore

@@ -0,0 +1,5 @@
+# ignore everything...
+/*
+!.gitignore
+# ...except for these:
+!config.yml

+ 132 - 0
.config/lazygit/config.yml

@@ -0,0 +1,132 @@
+### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
+# config.yml
+#
+# Docs:
+# * https://github.com/jesseduffield/lazygit/blob/master/docs/Config.md
+### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ### ###
+
+gui:
+  scrollPastBottom: false
+  mouseEvents: false
+  nerdFontsVersion: "3"
+  border: "single"
+git:
+  overrideGpg: true
+  commit:
+    autoWrapCommitMessage: true
+    autoWrapWidth: 72
+os:
+  edit: "floaterm {{filename}}"
+  editInTerminal: false
+refresher:
+  refreshInterval: 2
+
+customCommands:
+  - key: "<c-c>"
+    context: "files"
+    description: "Create a conventional commit"
+    command: |
+      git commit --allow-empty \
+      -m "$(python3 -c "from sys import argv; output = argv[1]; output += ('(' + argv[2].lower().replace(' ', '-') + ')' if len(argv[2]) > 0 else ''); output += ('' if len(argv[3]) <= 0 or argv[3].lower() == 'no' else '!'); output += ': ' + argv[4]; print(output);" "{{.Form.Type}}" "{{.Form.Scope}}" "{{.Form.Breaking}}" "{{.Form.Subject}}" )" \
+      -m "$(python3 -c "from sys import argv; print('BREAKING CHANGE: ' + argv[-1] if len(argv[-1]) > 0 and argv[-1].lower() not in ['no', 'yes'] else '');" "{{.Form.Breaking}}")"
+    prompts:
+      - type: "menu"
+        key: "Type"
+        title: "Type"
+        options:
+          - name: "feat"
+            description: "A new feature"
+            value: "feat"
+          - name: "fix"
+            description: "A bug fix"
+            value: "fix"
+          - name: "test"
+            description: "Adding missing tests or correcting existing tests"
+            value: "test"
+          - name: "chore"
+            description:
+              "Changes that do not modify the source code or test files"
+            value: "chore"
+          - name: " "
+            description: ""
+            value: "chore" # This line is just here for aesthetics, but should still have a valid value
+          - name: "build"
+            description:
+              "Changes that affect the build system or external dependencies"
+            value: "build"
+          - name: "ci"
+            description: "Changes to CI configuration files and scripts"
+            value: "ci"
+          - name: "docs"
+            description: "Documentation changes"
+            value: "docs"
+          - name: "perf"
+            description: "A code change that improves performance"
+            value: "perf"
+          - name: "refactor"
+            description:
+              "A code change that neither fixes a bug nor adds a feature"
+            value: "refactor"
+          - name: "revert"
+            description: "Reverts a previous commit"
+            value: "revert"
+          - name: "style"
+            description: "Changes that do not affect the meaning of the code"
+            value: "style"
+      - type: "input"
+        key: "Scope"
+        title: "Scope (optional)"
+        suggestions:
+          command: |
+            git log --pretty='format:%s' | \
+            rg '^\S+\((.*?)\)' -or '$1' | \
+            cat -n | \
+            sort -uk2 | \
+            sort -n | \
+            cut -f2-
+      - type: "input"
+        title: "Breaking Change (`no`, `yes`, or custom description)"
+        key: "Breaking"
+        initialValue: "no"
+        suggestions:
+          command: "echo yes"
+      - type: "input"
+        key: "Subject"
+        # Did you know? The preference for the imperative mood is included in the Pro Git book!
+        # https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project
+        title: "Description (<= 50 characters, in imperative mood)"
+      - type: "confirm"
+        title: "Confirm"
+        body: |
+          {{.Form.Type}}: {{.Form.Subject}}
+
+          Scope: {{.Form.Scope}}
+          Breaking Change: {{.Form.Breaking}}
+
+  - key: "<c-a>"
+    context: "commits"
+    description: "Modify author date and commit date"
+    command: |
+      export GIT_SEQUENCE_EDITOR="python3 -c \"from sys import argv; from re import sub, MULTILINE; path = argv[-1]; file = open(path, 'r'); content = sub('^pick ', 'edit ', file.read(), 1, flags=MULTILINE); file.close(); file = open(path, 'w'); file.write(content); file.close();\"";
+      git rebase --interactive --autostash --keep-empty --no-autosquash --rebase-merges {{.SelectedLocalCommit.Sha}}~;
+      export GIT_COMMITTER_DATE="{{.Form.Timestamp}}";
+      git commit --allow-empty --only --no-edit --amend --date="{{.Form.Timestamp}}";
+      git rebase --continue
+    prompts:
+      - type: "menuFromCommand"
+        title: "Select Timestamp"
+        key: "InitialValue"
+        command: |
+          bash -c "date \"+%Y-%m-%d %H:%M:%S %z\";
+          git log -7 --pretty=format:%ad --date=iso;
+          echo;
+          echo 2005-04-07 15:13:13 -0700;
+          echo 0000-00-00 00:00:00 +0000;"
+      - type: "input"
+        title: "Edit Timestamp"
+        key: "Timestamp"
+        initialValue: "{{.Form.InitialValue}}"
+      - type: "confirm"
+        title: "Confirm"
+        body: |
+          Set author and commit dates for commit "{{.SelectedLocalCommit.Name}}" ({{.SelectedLocalCommit.Sha}}) to "{{.Form.Timestamp}}"?'

+ 5 - 0
.github/README.md

@@ -40,6 +40,11 @@ A color scheme inspired by [JetBrain's](https://www.jetbrains.com/)
 Configuration for [lazydocker](https://github.com/jesseduffield/lazydocker/), a
 simple terminal UI for both docker and docker-compose.
 
+### [lazygit (`~/.config/lazygit/`)](./.config/lazygit/)
+
+Configuration for [lazygit](https://github.com/jesseduffield/lazygit/), a simple
+terminal UI for git commands.
+
 ### [tmux (`~/.config/tmux/`)](./.config/tmux/)
 
 Configuration for [tmux](https://github.com/tmux/tmux), a terminal multiplexer.