Help you create code snippet for your hdtyper terminal
- install by
hdtyper install hdtyper-snippet
and restart your terminal - open hdtyper-snippet by type
open hconf
and hitTAB
, this will expand the command to "open ~/.hdtyper_plugins/hdtyper-snippet.js", hitENTER
to open it - Add the snippet in
hdtyper-snippet.js
as following:
module.exports = {
// the command you want define snippet
"ssh":{
"server1":"root@198.162.1.1" // the snippet name and the content
}
}
- Refresh your terminal or restart it and type
ssh server1
and hitTAB
, this will expand the command tossh root@198.162.1.1
The Command Level snippet is like <command> <snippet-name>
. You can expand the snippet by hit TAB
. This will replace the <snippet-name>
with the <text>
you defined.
To define Command Level snippet, add the following inside hdtyper-snippet.js
module.exports = {
...
// the command you want define snippet
"<command>":{
"<snippet-name>":"<text>" // the snippet name and the content
}
...
}
The Sub Command Level snippet is like <command> <sub-command> <snippet-name>
. You can expand the snippet by hit TAB
. This will replace the <snippet-name>
with the <text>
you defined.
To define Sub Command level snippet, add the following inside hdtyper-snippet.js
module.exports = {
...
// the command you want define snippet
"<command>":{
$subcmds:{
"<sub-command>":"<text>"
}
}
...
}
You can use 2 variables #CLIP#
and #END#
inside the text.
#CLIP#
will replace the #CLIP#
with the text inside your clipboard after you expand the snippet.
Here is a sample for snippet which is useful to clone projet from git
// snippet definition
module.exports = {
...
// the snippet to debug docker, when expand, the id of the docker container is from clipboard
"git":{
c:"clone #CLIP#"
}
...
}
#END#
indicate where your cursor will show after expanding the snippet
Here is a sample for snippet which is useful to run docker container
// snippet definition
module.exports = {
...
// the snippet to run docker container, when expand, the cursor move before the name of docker image, you can continue to add other options
"docker":{
rr:"run #END# #CLIP#"
}
...
}
Here is a demo for it
TODO
TODO