summaryrefslogtreecommitdiffstats
path: root/doc/documentation.md
blob: d6df5c22d8ed7630c96eaa41d030c728b18159aa (plain)
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
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
<!-- DO NOT EDIT -->
<!-- This file is auto-generated by grv -->

# GRV Documentation


## Introduction

GRV - Git Repository Viewer - is a TUI for viewing and modifying Git repositories.
The sections below provide an overview of the ways to configure and interact with GRV.


## Table Of Contents

 - [Command Line Arguments](#command-line-arguments)
 - [Key Bindings](#key-bindings)
     * [Movement](#movement)
     * [Search](#search)
     * [View Navigation](#view-navigation)
     * [General](#general)
     * [RefView Specific](#refview-specific)
     * [CommitView Specific](#commitview-specific)
     * [GitStatusView Specific](#gitstatusview-specific)
     * [MessageBoxView Specific](#messageboxview-specific)
     * [RemoteView Specific](#remoteview-specific)
 - [Configuration Variables](#configuration-variables)
 - [Configuration Commands](#configuration-commands)
     * [addtab](#addtab)
     * [addview](#addview)
     * [def](#def)
     * [evalkeys](#evalkeys)
     * [git](#git)
     * [giti](#giti)
     * [help](#help)
     * [hsplit](#hsplit)
     * [map](#map)
     * [q](#q)
     * [rmtab](#rmtab)
     * [set](#set)
     * [sleep](#sleep)
     * [split](#split)
     * [theme](#theme)
     * [undef](#undef)
     * [unmap](#unmap)
     * [vsplit](#vsplit)
 - [Shell Commands](#shell-commands)
 - [Filter Query Language](#filter-query-language)


## Command Line Arguments

GRV accepts the following command line arguments:

```
-logFile string
	Log file path (default "grv.log")
-logLevel string
	Logging level [NONE|PANIC|FATAL|ERROR|WARN|INFO|DEBUG|TRACE] (default "NONE")
-readOnly
	Run grv in read only mode
-repoFilePath string
	Repository file path (default ".")
-version
	Print version
-workTreeFilePath string
	Work tree file path
```


## Key Bindings

The following tables contain default and user configured key bindings

### Movement

```
 Key Bindings      | Action                     | Description                                 
 ------------------+----------------------------+----------------------------------------------
 z., zz            | <grv-center-view>          | Center view                                 
 L                 | <grv-cursor-bottom-view>   | Move to the last line of the page           
 M                 | <grv-cursor-middle-view>   | Move to the middle line of the page         
 H                 | <grv-cursor-top-view>      | Move to the first line of the page          
 gg                | <grv-first-line>           | Move to first line                          
 G                 | <grv-last-line>            | Move to last line                           
 <C-d>             | <grv-next-half-page>       | Move half page down                         
 <Down>, j         | <grv-next-line>            | Move down one line                          
 <PageDown>, <C-f> | <grv-next-page>            | Move one page down                          
 <C-u>             | <grv-prev-half-page>       | Move half page up                           
 <Up>, k           | <grv-prev-line>            | Move up one line                            
 <PageUp>, <C-b>   | <grv-prev-page>            | Move one page up                            
 zb                | <grv-scroll-cursor-bottom> | Scroll the screen so cursor is at the bottom
 zt                | <grv-scroll-cursor-top>    | Scroll the screen so cursor is at the top   
 <Left>, h         | <grv-scroll-left>          | Scroll left                                 
 <Right>, l        | <grv-scroll-right>         | Scroll right                                
```

### Search

```
 Key Bindings | Action                      | Description                  
 -------------+-----------------------------+-------------------------------
 None         | <grv-clear-search>          | Clear search                 
 ?            | <grv-reverse-search-prompt> | Search backwards             
 n            | <grv-search-find-next>      | Move to next search match    
 N            | <grv-search-find-prev>      | Move to previous search match
 /            | <grv-search-prompt>         | Search forwards              
```

### View Navigation

```
 Key Bindings              | Action                   | Description                       
 --------------------------+--------------------------+------------------------------------
 <C-w>o, <C-w><C-o>, f     | <grv-full-screen-view>   | Toggle current view full screen   
 gt                        | <grv-next-tab>           | Move to next tab                  
 <C-w>w, <C-w><C-w>, <Tab> | <grv-next-view>          | Move to next view                 
 gT                        | <grv-prev-tab>           | Move to previous tab              
 <C-w>W, <S-Tab>           | <grv-prev-view>          | Move to previous view             
 q                         | <grv-remove-view>        | Close view (or close tab if empty)
 <C-w>t                    | <grv-toggle-view-layout> | Toggle view layout                
```

### General

```
 Key Bindings | Action                       | Description                                     
 -------------+------------------------------+--------------------------------------------------
 None         | <grv-exit>                   | Exit GRV                                        
 :            | <grv-prompt>                 | GRV Command prompt                              
 None         | <grv-remove-tab>             | Remove the active tab                           
 <Enter>      | <grv-select>                 | Select item (opens listener view if none exists)
 <C-a>        | <grv-show-available-actions> | Show available actions for the selected row     
 None         | <grv-show-help>              | Show the help view                              
 <C-z>        | <grv-suspend>                | Suspend GRV                                     
```

### RefView Specific

```
 Key Bindings | Action                           | Description                               
 -------------+----------------------------------+--------------------------------------------
 -            | <grv-checkout-previous-ref>      | Checkout previous ref                     
 c            | <grv-checkout-ref>               | Checkout ref                              
 T            | <grv-create-annotated-tag>       | Create a new annotated tag                
 B            | <grv-create-branch-and-checkout> | Create a new branch and checkout          
 b            | <grv-create-branch>              | Create a new branch                       
 t            | <grv-create-tag>                 | Create a new tag                          
 D            | <grv-delete-ref>                 | Delete ref                                
 <C-q>        | <grv-filter-prompt>              | Add filter                                
 m            | <grv-merge-ref>                  | Merge ref into current branch             
 p            | <grv-push-ref>                   | Push ref to remote                        
 r            | <grv-rebase>                     | Rebase current branch onto selected branch
 <C-r>        | <grv-remove-filter>              | Remove filter                             
```

### CommitView Specific

```
 Key Bindings | Action                           | Description                     
 -------------+----------------------------------+----------------------------------
 c            | <grv-checkout-commit>            | Checkout commit                 
 T            | <grv-create-annotated-tag>       | Create a new annotated tag      
 B            | <grv-create-branch-and-checkout> | Create a new branch and checkout
 b            | <grv-create-branch>              | Create a new branch             
 t            | <grv-create-tag>                 | Create a new tag                
 <C-q>        | <grv-filter-prompt>              | Add filter                      
 <C-r>        | <grv-remove-filter>              | Remove filter                   
```

### GitStatusView Specific

```
 Key Bindings | Action                    | Description 
 -------------+---------------------------+--------------
 A            | <grv-action-amend-commit> | Amend commit
 C            | <grv-action-commit>       | Commit      
 c            | <grv-checkout-file>       | Checkout    
 a            | <grv-stage-file>          | Stage       
 u            | <grv-unstage-file>        | Unstage     
```

### MessageBoxView Specific

```
 Key Bindings       | Action            | Description               
 -------------------+-------------------+----------------------------
 <Right>, l, <Tab>  | <grv-next-button> | Select the next button    
 <Left>, h, <S-Tab> | <grv-prev-button> | Select the previous button
```

### RemoteView Specific

```
 Key Bindings | Action            | Description
 -------------+-------------------+-------------
 p            | <grv-pull-remote> | Pull remote
```


## Configuration Variables

Configuration variables allow features to be enabled, disabled and configured.
They are specified using the set command in the grvrc file or at the command prompt

```
 Variable                   | Type   | Default Value | Description                                                                 
 ---------------------------+--------+---------------+------------------------------------------------------------------------------
 commit-graph               | bool   | false         | Commit graph visible                                                        
 commit-limit               | string | 100000        | Limit the number of commits loaded. Allowed values: number, date, oid or tag
 confirm-checkout           | bool   | true          | Confirm before performing git checkout                                      
 default-view               | string |               | Command to generate a custom default view on start up                       
 diff-display               | string | fancy         | Diff display format                                                         
 git-binary-file-path       | string |               | File path to git binary. Required only when git binary is not in $PATH      
 input-prompt-after-command | bool   | true          | Display "Press any key to continue" after executing external command        
 mouse                      | bool   | false         | Mouse support enabled                                                       
 mouse-scroll-rows          | int    | 3             | Number of rows scrolled for each mouse event                                
 prompt-history-size        | int    | 1000          | Maximum number of prompt entries retained                                   
 tabwidth                   | int    | 8             | Tab character screen width (minimum value: 1)                               
 theme                      | string | solarized     | The currently active theme                                                  
```


## Configuration Commands

The behaviour of GRV can be customised through the use of commands specified in a configuration file
GRV will look for the following configuration files on start up:

```
 - $XDG_CONFIG_HOME/grv/grvrc
 - $HOME/.config/grv/grvrc
```

GRV will attempt to process the first file which exists.
Commands can also be specified within GRV using the command prompt :

Below are the set of configuration commands supported:

### addtab

The addtab command creates a new named empty tab and switches to this new tab.
The format of the command is:

```
addtab tabname
```

For example, to add a new tab titled "mycustomtab" the following command can be used:

```
addtab mycustomtab
```

### addview

The addview command allows a view to be added to the currently active tab.
The form of the command is:

```
addview view viewargs...
```

Each view accepts a different set of arguments. This is described in the table below:

```
 View          | Args      
 --------------+------------
 CommitView    | ref or oid
 DiffView      | oid       
 GitStatusView | none      
 RefView       | none      
```

Examples usages for each view are given below:

```
addview CommitView origin/master
addview DiffView 4882ca9044661b49a26ae03ceb1be3a70d00c6a2
addview GitStatusView
addview RefView
```

### def

The def command allows a custom GRV command to be defined. It has the form:

```
def NAME {
	BODY
}
```

where NAME is the name of the new command and BODY is a sequence of commands to execute.
For example, to define a command "maintab" to open a new tab containing the CommitView for master:

```
def maintab {
	addtab Main
	addview CommitView master
}
```

This command can be invoked at the command prompt with:

```
:maintab
```

The command body can contain argument placeholders that will be substituted on invocation.
Argument placeholders have the form $n or ${n} where n is an integer greater than zero corresponding to the argument to substitute.
For example, the "maintab" command defined earlier can be altered to accept the branch in as an argument:

```
def maintab {
	addtab Main
	addview CommitView $1
}
```

To invoke this command for the branch "feature-branch" and open a new tab containing the commit view for this branch:

```
:maintab feature-branch
```

All arguments can be substituted using the placeholder $@ or ${@}
For example, the following command acts as an alias for the vsplit command:

```
def vs { vsplit $@ }
```

and can be invoked with:

```
:vs CommitView master
```

Argument placeholders can be escaped by prepending a dollar sign.
For example, to specify the literal string $1 in a command body specify $$1.

### evalkeys

The evalkeys command executes the provided key string sequence.
The format of the command is:

```
evalkeys keys
```

For example, running the following will switch to the next tab:

```
evalkeys <grv-next-tab>
```

### git

The git command is an alias to the git cli command.
It allows a non-interactive git command to run without having to leave GRV.
A pop-up window displays the output of the command.
For example, to run 'git status' from within GRV use the following key sequence

```
:git status
```

Only non-interactive git commands (i.e. those that require no user input) can be run using the git command.
For interactive git commands the giti command can be used.

### giti

The git command is an alias to the git cli command.
It allows an interactive git command (i.e. those that require user input) to be run without having to leave GRV.
The command is executed in the controlling terminal and GRV is resumed on command completion.
For example, to run 'git rebase -i HEAD~2' use the following key sequence:

```
:giti rebase -i HEAD~2
```

### help

The help command opens a tab containing documentation for GRV.
A search term can be provided as an argument. For example:

```
help vsplit
```

will display the section for the command vsplit in the help tab

### hsplit

The hsplit command creates a horizontal split between the currently selected view and the view specified in the command.
The form of the command is:

```
hsplit view viewargs...
```

For example, to create a horizontal split between the currently selected view and a RefView:

```
hsplit RefView
```

### map

The map command allows a key sequence to be mapped to an action, another key sequence or a shell command for a specified view.
The form of the map command is:

```
map view fromkeys tokeys
```

For example, to map the key 'a' to the keys 'gg' in the Ref View:

```
map RefView a gg
```

When pressing 'a' in the Ref View, the first line would then become the selected line, as 'gg' moves the cursor to the first line.
All is a valid view argument when a binding should apply to all views.

GRV also has a text representation of actions that are independent of key bindings.
For example, the following commands can be used to make the <Up> key move a line down and the <Down> key move a line up:

```
map All <Up> <grv-next-line>
map All <Down> <grv-prev-line>
```

The map command also allows a key sequence to be mapped directly to a shell command.
Prefix a shell command with the '!' character. For example, to map the key 'a' to the shell command 'ls -lh':

```
map All a !ls -lh
```

The set of actions available is described in the key binding tables above.

### q

The quit command is used to exit GRV and can be used with the following keys:

```
:q<Enter>
```

### rmtab

The rmtab removes the currently active tab. If the tab removed is the