-
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
edf5d7f
commit 50b64d3
Showing
17 changed files
with
96 additions
and
89 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
exports.clearBuffer = ({ app, uid }, cmd = 'printf "\\033[H"') => | ||
app.sessions.get(uid).write(`${cmd} \r`) | ||
exports.clearBuffer = ({ app, uid }, cmd = 'printf "\\033[H"') => | ||
app.sessions.get(uid).write(`${cmd} \r`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,27 @@ | ||
const Path = require('path') | ||
|
||
const KNOWN_SHELLS = { | ||
powershell: { separator: '; ', clearCommand: 'Clear-Host' }, | ||
node: { separator: '; ', clearCommand: 'console.clear();' }, | ||
cmd: { separator: ' & ', clearCommand: 'cls' }, | ||
fish: { separator: ' & ', clearCommand: 'clear'}, | ||
fallback: { separator: ' && ', clearCommand: 'printf "\\033[H"' }, | ||
powershell: { separator: '; ', clearCommand: 'Clear-Host' }, | ||
node: { separator: '; ', clearCommand: 'console.clear();' }, | ||
cmd: { separator: ' & ', clearCommand: 'cls' }, | ||
fish: { separator: ' & ', clearCommand: 'clear' }, | ||
fallback: { separator: ' && ', clearCommand: 'printf "\\033[H"' }, | ||
} | ||
|
||
exports.getSeparator = (browserWindow, uid) => { | ||
let shellName = Path.parse(browserWindow.sessions.get(uid).shell).name.toLowerCase() || null | ||
return KNOWN_SHELLS[shellName] ? KNOWN_SHELLS[shellName].separator : KNOWN_SHELLS.fallback.separator // Separator not found | ||
let shellName = | ||
Path.parse(browserWindow.sessions.get(uid).shell).name.toLowerCase() || null | ||
|
||
return KNOWN_SHELLS[shellName] | ||
? KNOWN_SHELLS[shellName].separator | ||
: KNOWN_SHELLS.fallback.separator // Separator not found | ||
} | ||
|
||
exports.getClearCommand = (browserWindow, uid) => { | ||
let shellName = Path.parse(browserWindow.sessions.get(uid).shell).name.toLowerCase() || null | ||
return KNOWN_SHELLS[shellName] ? KNOWN_SHELLS[shellName].clearCommand : KNOWN_SHELLS['fallback'].clearCommand // Command not found | ||
} | ||
let shellName = | ||
Path.parse(browserWindow.sessions.get(uid).shell).name.toLowerCase() || null | ||
|
||
return KNOWN_SHELLS[shellName] | ||
? KNOWN_SHELLS[shellName].clearCommand | ||
: KNOWN_SHELLS['fallback'].clearCommand // Command not found | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
const { numberOfWindows } = require('../number-of-windows') | ||
|
||
exports.isNewWindow = terminal => | ||
!terminal.splitDirection && | ||
exports.isNewWindow = (terminal) => | ||
!terminal.splitDirection && | ||
Object.keys(terminal).length <= 2 && | ||
numberOfWindows() > 2 | ||
numberOfWindows() > 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
const { numberOfWindows } = require('../number-of-windows') | ||
|
||
exports.isOnce = terminal => | ||
numberOfWindows() <= 2 && | ||
Object.keys(terminal).length <= 2 | ||
exports.isOnce = (terminal) => | ||
numberOfWindows() <= 2 && Object.keys(terminal).length <= 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
const rules = require('../rules/index') | ||
|
||
exports.isRule = rule => rule in rules | ||
exports.isRule = (rule) => rule in rules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,4 @@ | ||
exports.isTab = terminal => | ||
terminal.uid ? | ||
!terminal[terminal.uid].direction && | ||
Object.keys(terminal.tabs).length > 1 : | ||
'' | ||
exports.isTab = (terminal) => | ||
terminal.uid | ||
? !terminal[terminal.uid].direction && Object.keys(terminal.tabs).length > 1 | ||
: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
exports.joinCommands = (commands, commandSeparator = ' && ') => commands.join(commandSeparator) | ||
exports.joinCommands = (commands, commandSeparator = ' && ') => | ||
commands.join(commandSeparator) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,3 @@ | ||
const { BrowserWindow } = require('electron') | ||
|
||
exports.numberOfWindows = () => | ||
BrowserWindow.getAllWindows().length | ||
exports.numberOfWindows = () => BrowserWindow.getAllWindows().length |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
exports.onAllRule = ({ app, uid, cmd }) => | ||
app.sessions.get(uid).write(`${cmd}\r`) | ||
exports.onAllRule = ({ app, uid, cmd }) => | ||
app.sessions.get(uid).write(`${cmd}\r`) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
const { isNewWindow } = require('../is/is-new-window') | ||
|
||
exports.onNewWindowRule = ({ app, uid, terminal, cmd }) => | ||
isNewWindow(terminal) ? | ||
app.sessions.get(uid).write(`${cmd}\r`) : | ||
'' | ||
exports.onNewWindowRule = ({ app, uid, terminal, cmd }) => | ||
isNewWindow(terminal) ? app.sessions.get(uid).write(`${cmd}\r`) : '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,2 @@ | ||
exports.onSplittedWindowsRule = ({ app, uid, cmd, terminal }) => | ||
!!terminal.splitDirection ? | ||
app.sessions.get(uid).write(`${cmd}\r`) : | ||
'' | ||
!!terminal.splitDirection ? app.sessions.get(uid).write(`${cmd}\r`) : '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
const { isTab } = require('../is/is-tab') | ||
|
||
exports.onTabsRule = ({ app, uid, terminal, cmd }) => | ||
isTab(terminal) && | ||
!terminal.splitDirection ? | ||
app.sessions.get(uid).write(`${cmd}\r`) : | ||
'' | ||
isTab(terminal) && !terminal.splitDirection | ||
? app.sessions.get(uid).write(`${cmd}\r`) | ||
: '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,4 @@ | ||
const { isOnce } = require('../is/is-once') | ||
|
||
exports.onceRule = ({ app, uid, terminal, cmd }) => | ||
isOnce(terminal) ? | ||
app.sessions.get(uid).write(`${cmd}\r`) : | ||
'' | ||
isOnce(terminal) ? app.sessions.get(uid).write(`${cmd}\r`) : '' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
module.exports = waitFor = (object, key, fn) => | ||
key in object ? | ||
fn(object[key]) : | ||
setTimeout(() => waitFor(object, key, fn), 10) | ||
key in object | ||
? fn(object[key]) | ||
: setTimeout(() => waitFor(object, key, fn), 10) |