aboutsummaryrefslogtreecommitdiffstats
path: root/config/yazi/plugins/yatline-githead.yazi/README.md
blob: e2af22e20caa7043ba23a0b6ca6eab50483d890f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
# yatline-githead.yazi

Manual clone of [githead.yazi](https://github.com/llanosrocas/githead.yazi) for supporting [yatline.yazi](https://github.com/imsi32/yatline.yazi)

> [!IMPORTANT]
> This repository will not add new features other than coming from original repository.  
> The latest commit in there is 317d09f728928943f0af72ff6ce31ea335351202.
> Which can be found in [here](https://github.com/llanosrocas/githead.yazi/commit/317d09f728928943f0af72ff6ce31ea335351202)

All supported features are listed [here](#features)

## Requirements

- yazi version >= 25.5.28.
- Font with symbol support. For example [Nerd Fonts](https://www.nerdfonts.com/).
- [yatline.yazi](https://github.com/imsi32/yatline.yazi) (Mandatory)

> [!IMPORTANT]
> Recommended to use [githead.yazi](https://github.com/llanosrocas/githead.yazi), if you are not using yatline.yazi

## Installation

```sh
ya pkg add imsi32/yatline-githead
```

## Usage

Add this to your `~/.config/yazi/init.lua`, after yatline.yazi configuration:

```lua
require("yatline-githead"):setup()
```

### Default Configuration

```lua
require("yatline-githead"):setup({
  order = {
    "branch",
    "remote",
    "tag",
    "commit",
    "behind_ahead_remote",
    "stashes",
    "state",
    "staged",
    "unstaged",
    "untracked",
  },

  show_numbers = true, -- shows staged, unstaged, untracked, stashes count

  show_branch = true,
  branch_prefix = "",
  branch_color = "blue",
  branch_symbol = "",
  branch_borders = "",

  show_remote_branch = true, -- only shown if different from local branch
  always_show_remote_branch = false, -- always show remote branch even if it the same as local branch
  always_show_remote_repo = false, -- Adds `origin/` if `always_show_remote_branch` is enabled
  remote_branch_prefix = ":",
  remote_branch_color = "bright magenta",

  show_tag = true, -- only shown if branch is not available
  always_show_tag = false,
  tag_color = "magenta",
  tag_symbol = "#",

  show_commit = true, -- only shown if branch AND tag are not available
  always_show_commit = false,
  commit_color = "bright magenta",
  commit_symbol = "@",

  show_behind_ahead_remote = true,
  behind_remote_color = "bright magenta",
  behind_remote_symbol = "⇣",
  ahead_remote_color = "bright magenta",
  ahead_remote_symbol = "⇡",

  show_stashes = true,
  stashes_color = "bright magenta",
  stashes_symbol = "$",

  show_state = true,
  show_state_prefix = true,
  state_color = "red",
  state_symbol = "~",

  show_staged = true,
  staged_color = "bright yellow",
  staged_symbol = "+",

  show_unstaged = true,
  unstaged_color = "bright yellow",
  unstaged_symbol = "!",

  show_untracked = true,
  untracked_color = "blue",
  untracked_symbol = "?",
})
```

### Theme

You can also use a [theme](https://github.com/imsi32/yatline-themes):

```lua
local your_theme = {
  branch_color = "blue",
  remote_branch_color = "bright magenta",
  tag_color = "magenta",
  commit_color = "bright magenta",
  behind_remote_color = "bright magenta",
  ahead_remote_color = "bright magenta",
  stashes_color = "bright magenta",
  state_color = "red",
  staged_color = "bright yellow",
  unstaged_color = "bright yellow",
  untracked_color = "blue",
}

require("yatline-githead"):setup({
-- ===
    
  theme = your_theme,

-- ===
})
```

### Adding as a Component

If you are using yatline.yazi, you can use this component:

``` lua
-- ===

  {type = "coloreds", custom = false, name = "githead"},

-- ===
```

``` text
/cwd on ( feature):origin/main #v1.0.0 #1234567 ⇣2⇡3 $1 rebase 1/2 ~2 +4 !1 ?5
|    |   |  |     ││ |     |    |       |        | |  |  |          |  |  |  |
|    |   |  |     ││ |     |    |       |        | |  |  |          |  |  |  └─── untracked_symbol
|    |   |  |     ││ |     |    |       |        | |  |  |          |  |  └────── unstaged_symbol
|    |   |  |     ││ |     |    |       |        | |  |  |          |  └───────── staged_symbol
|    |   |  |     ││ |     |    |       |        | |  |  |          └──────────── state_symbol
|    |   |  |     ││ |     |    |       |        | |  |  └─────────────────────── state_prefix
|    |   |  |     ││ |     |    |       |        | |  └────────────────────────── stashes_symbol
|    |   |  |     ││ |     |    |       |        | └───────────────────────────── ahead_symbol
|    |   |  |     ││ |     |    |       |        └─────────────────────────────── behind_symbol
|    |   |  |     ││ |     |    |       └──────────────────────────────────────── commit_symbol
|    |   |  |     ││ |     |    └──────────────────────────────────────────────── tag_symbol
|    |   |  |     ││ |     └───────────────────────────────────────────────────── remote_branch
|    |   |  |     ││ └─────────────────────────────────────────────────────────── remote_repo
|    |   |  |     |└───────────────────────────────────────────────────────────── remote_branch_prefix
|    |   |  |     └────────────────────────────────────────────────────────────── branch_borders
|    |   |  └──────────────────────────────────────────────────────────────────── branch
|    |   └─────────────────────────────────────────────────────────────────────── branch_symbol
|    └─────────────────────────────────────────────────────────────────────────── branch_prefix
└──────────────────────────────────────────────────────────────────────────────── cwd
```

## Features

- [x] Current branch
- [x] Remote and remote branch
- [x] Latest tag
- [x] Latest commit
- [x] Behind/Ahead of the remote
- [x] Stashes
- [x] States
  - [x] merge
  - [x] cherry
  - [x] rebase (+ done counter)
  - [x] revert
  - [x] bisect
- [x] Staged
- [x] Unstaged
- [x] Untracked

### Under the hood

The goal is to use minimum amount of shell commands.

- Branch, stashes, staged files, unstaged files, untracked files.

```shell
git status --ignore-submodules=dirty --branch --show-stash --ahead-behind
```

- Remote branch and repo:

```shell
git rev-parse --abbrev-ref --symbolic-full-name @{upstream}
```

- Latest tag and commit:

```shell
git log --format="commit %h%d" -n 1
```

## Credits

- [githead.yazi](https://github.com/llanosrocas/githead.yazi)
- [yazi source code](https://github.com/sxyazi/yazi)
- [powerlevel10k](https://github.com/romkatv/powerlevel10k)
- [twio142](https://github.com/twio142/githead.yazi)
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage