-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommands.rst
More file actions
148 lines (96 loc) · 4.64 KB
/
Copy pathcommands.rst
File metadata and controls
148 lines (96 loc) · 4.64 KB
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
Custom Commands
===============
:gfversion:`New in v1.3.0.`
You can augment |App|'s capabilities with **custom commands** tailored to your
workflow. These let you launch commands in a terminal directly from |App|.
You can even send items that you manipulate in the UI as **arguments** to the
commands. These include the selected commit, file, branch, etc.
To define custom commands, go to |cogwheel| :menuselection:`Settings --> Custom
Commands` and simply enter some commands (one per line). Here is a useful sample
to get you started:
.. code-block:: bash
# Feel free to copy/paste this sample into Custom Commands.
git rebase -i $COMMIT # &Interactive Rebase
git rebase --continue # &Continue Rebase
? git rebase --abort # &Abort Rebase
git diff $COMMIT HEAD # Diff Commit With &HEAD
After you click OK in the Settings, notice the `Commands` menu that appears in
the main menu bar. You're now ready to invoke your commands from this menu.
.. figure:: /assets/screens/commandsmenu.png
The Commands menu that appears once you've defined at least one Custom Command.
.. tip:: If you've chosen to hide the menu bar, you can also access your
commands via a pulldown menu attached to the :gficonlabel:`terminal Terminal`
button in the toolbar.
.. tip:: To select which terminal program to use, go to |cogwheel| :menuselection:`Settings --> External Tools --> Terminal`.
Argument placeholders
---------------------
You may use the following placeholders in your commands:
.. list-table::
:header-rows: 1
* - Token
- Description
* - $COMMIT
- SHA-1 hash of the selected commit in the history
* - $FILE
- Path to the selected file (relative)
* - $FILEABS
- Path to the selected file (absolute)
* - $FILEDIR
- Path to the selected file's parent directory (relative)
* - $FILEDIRABS
- Path to the selected file's parent directory (absolute)
* - $HEAD
- SHA-1 hash of the HEAD commit
* - $HEADBRANCH
- Ref name of the HEAD branch
* - $HEADUPSTREAM
- Ref name of the HEAD branch's upstream
* - $REF
- Name of the selected ref in the sidebar (local branches, remote branches, tags)
* - $REMOTE
- Name of the selected remote in the sidebar
* - $WORKDIR
- Path to the repository's working directory (absolute)
Titles and separators
---------------------
The :code:`#` character starts a **comment** until the end of the line.
If you add a comment after a command (on the same line), then the comment will
serve as the **title** of the command in the menu.
To create a **separator** in the menu, insert a comment line of dashes
(:code:`#---`) in between two commands.
.. code-block:: bash
echo 'hello world 1'
# The command above had no custom title.
# Let's define a custom title for the next one.
echo 'hello world 2' # Say Hello (this is a custom title)
# Let's add a separator in the menu.
# -----------------
echo 'hello world 3'
.. figure:: /assets/screens/commandstitlesep.png
The example above rendered in the Commands menu (separator and custom title).
Keyboard shortcuts
------------------
.. figure:: /assets/screens/commandsaccelerator.png
:align: right
A command titled :code:`&Rebase`.
When you set a custom title for a command, you can define an **accelerator key**
for this command by inserting :code:`&` before some letter in the command title.
For example, titling a command :code:`&Rebase` would assign accelerator key :kbd:`R` to the command.
You can trigger accelerator keys in one of two ways:
- Press :kbd:`Ctrl K`, then your command's accelerator key (e.g. :kbd:`Ctrl K` then :kbd:`R`).
.. note:: Let go of :kbd:`Ctrl K` before pressing the accelerator key.
- Or, pull down the :menuselection:`Commands` menu with :kbd:`Alt C`, then press your accelerator key (e.g. :kbd:`Alt C` then :kbd:`R`).
Confirmation prompt
-------------------
By default, when you trigger any custom command, |App| will give you a chance to
review the prepared command before it's sent to the terminal (with the proper
substitutions).
You can turn off this behavior by unticking the checkbox at |cogwheel|
:menuselection:`Settings --> Custom Commands --> Ask for confirmation before
running any command`.
If you've turned off the confirmation dialog for all commands, you can still
force it to appear before specific commands. To do so, prepend the commands of
your choice with the :code:`?` character. We strongly recommend doing this for
commands that may have destructive effects!
For example, :code:`? git rebase --abort` will *always* ask you to confirm,
*even* if you've unticked `Ask for confirmation`.