You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+84-32Lines changed: 84 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
<palign="center">The ultimate and most complete extension to initialize commands before and after <ahref="https://hyper.is/">Hyper terminal</a> starts
6
6
<br/><br/>
7
-
<ahref="https://www.patreon.com/daltonmenezes"><imgsrc="https://img.shields.io/badge/become%20a-patron%20or%20sponsor-orange.svg"alt="become a patron or sponsor" /></a>
7
+
<ahref="https://www.patreon.com/daltonmenezes"><imgsrc="https://img.shields.io/badge/become%20a-patron%20or%20sponsor-orange.svg"alt="become a patron or sponsor" /></a>
> With **hyper-init** you can perform as many commands as you would like to do, before and after Hyper terminal starts, using rules that defines when your commands should run.
17
+
> With **hyper-init** you can perform as many commands as you would like to do, before and after Hyper terminal starts, using rules that define when your commands should run.
If you don't have Hyper, install it from [here](https://hyper.is/#installation).
37
+
If you don't have Hyper, install it [here](https://hyper.is/#installation).
35
38
36
39
So, type the following on Hyper:
37
40
@@ -41,11 +44,11 @@ hyper i hyper-init
41
44
42
45
## Configuration
43
46
44
-
## init
47
+
###init
45
48
46
-
```hyper-init``` can be configured in ```~/.hyper.js``` configuration file within the ```config``` object.
49
+
`hyper-init` can be configured within the `config` object in the `~/.hyper.js` configuration file.
47
50
48
-
All you have to do to get started is to create an array of objects called ```init```.
51
+
All you have to do to get started is to create an array of objects called `init`, like this:
49
52
50
53
```js
51
54
init: [
@@ -56,11 +59,11 @@ init: [
56
59
]
57
60
```
58
61
59
-
Your ```~/.hyper.js``` configuration file should look like this:
62
+
Your `~/.hyper.js` configuration file should look like this:
60
63
```js
61
64
module.exports= {
62
65
config: {
63
-
66
+
64
67
// add hyper-init configuration like this:
65
68
init: [
66
69
{
@@ -71,46 +74,95 @@ module.exports = {
71
74
rule:'windows',
72
75
commands: ['echo This is only executed on New Windows!']
73
76
}
74
-
]
77
+
]
75
78
},
76
79
77
80
plugins: ['hyper-init']
78
81
79
82
}
80
83
```
81
84
82
-
## clearCommand
85
+
#### Rules
86
+
A string that defines when you want your commands to run.
87
+
88
+
Rule | Description
89
+
--- | ---
90
+
`once` | executes your commands only at Hyper starts
91
+
`windows` | executes your commands only when a new Hyper window opens
92
+
`tabs` | executes your commands only when a new tab is opened
93
+
`splitted` | executes your commands only when a new pane is opened
94
+
`all` | executes your commands every time a terminal opens
95
+
96
+
#### Commands
97
+
An array with your shell commands to run.<br/>
98
+
You can perform as many commands as you would like.
99
+
100
+
Example:
101
+
```js
102
+
commands: ['cd ~/Desktop', 'ls']
103
+
```
104
+
83
105
84
-
Also `hyper-init` clears the terminal buffer using `printf "\\033[H"` as the default value, but you can set it manually adding the `clearCommand: ''` property within the `config` object. For example:
106
+
### clearCommand
107
+
108
+
`hyper-init` can infer the command to clear the screen for a small number of terminals.
109
+
If it can't infer the command, `hyper-init` clears the terminal buffer using `printf "\\033[H"`.
110
+
You can set it manually adding the `clearCommand: ''` property within the `config` object.
111
+
For example:
85
112
86
113
```js
87
114
module.exports= {
88
-
config: {
89
-
clearCommand:'reset'
90
-
}
115
+
config: {
116
+
clearCommand:'reset'
117
+
}
91
118
}
92
119
```
93
120
94
-
##init: Options
121
+
### commandSeparator
95
122
96
-
### Rules
97
-
A string that defines when you want your commands to run.
123
+
`hyper-init` uses ` && ` as the default separator for commands.
124
+
For known terminals, `hyper-init` can infer the separator.
125
+
You can also set it manually by adding the `commandSeparator: ''` property within the `config` object,
126
+
but this overrides for all terminals, even ones that don't support that delimiter.
127
+
For example:
98
128
99
-
Rule | Description
100
-
--- | ---
101
-
`once` | executes your commands only at Hyper starts
102
-
`windows` | executes your commands only at new windows
103
-
`tabs` | executes your commands only at new tabs
104
-
`splitted` | executes your commands only at splitted windows
105
-
`all` | executes your commands with all described states previously
129
+
```js
130
+
module.exports= {
131
+
config: {
132
+
commandSeparator:' ++ '// For an arbitrary terminal that uses `++`
133
+
}
134
+
}
135
+
```
106
136
107
-
### Commands
108
-
An array with your shell commands to run.<br/>
109
-
You can perform as many commands as you would like to do.
137
+
## Contributing
138
+
139
+
`hyper-init`'s ability to infer the `clearCommand` and `commandSeparator` is based on its relatively small dictionary.
140
+
Feel free to add more definitions for terminals not listed in `get-specifics.js`.
110
141
111
-
Example:
112
142
```js
113
-
commands: ['cd ~/Desktop', 'ls']
143
+
KNOWN_SHELLS= {
144
+
[...]
145
+
shellName: {
146
+
separator:'',
147
+
clearCommand:''
148
+
}
149
+
[...]
150
+
}
151
+
```
152
+
153
+
-`shellName` should be replaced with the name of the shell you want to target (lowercase)
154
+
- The value of `separator` should be the separator for multiple statements on one line (IE `' && '`) as a string
155
+
- The value of `clearCommand` should be the command to clear the target shell (IE `'cls'`) as a string
0 commit comments