diff options
author | Adrian Kummerlaender | 2015-12-12 23:37:11 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-12-12 23:37:11 +0100 |
commit | d1200ca432038a34a9fa063244136e737ce47735 (patch) | |
tree | d687b0fda491b2bac38defb8f42b96e6b08f459b | |
parent | e3f7344551a387653c2271ecc24d95051a04a2d1 (diff) | |
download | MetaTerm-d1200ca432038a34a9fa063244136e737ce47735.tar MetaTerm-d1200ca432038a34a9fa063244136e737ce47735.tar.gz MetaTerm-d1200ca432038a34a9fa063244136e737ce47735.tar.bz2 MetaTerm-d1200ca432038a34a9fa063244136e737ce47735.tar.lz MetaTerm-d1200ca432038a34a9fa063244136e737ce47735.tar.xz MetaTerm-d1200ca432038a34a9fa063244136e737ce47735.tar.zst MetaTerm-d1200ca432038a34a9fa063244136e737ce47735.zip |
Expose session PID and current working directory
-rw-r--r-- | main.cc | 6 | ||||
-rw-r--r-- | src/command/commands.js | 12 | ||||
-rw-r--r-- | src/widget/EmbeddedTerminal.qml | 5 |
3 files changed, 14 insertions, 9 deletions
@@ -20,6 +20,10 @@ class WorkingDirectory : public QObject { Q_INVOKABLE QString current() const { return QDir::current().absolutePath(); } + + Q_INVOKABLE QString currentOfPID(const int pid) const { + return QDir("/proc/" + QString::number(pid) + "/cwd/").canonicalPath(); + } }; int main(int argc, char *argv[]) { @@ -30,7 +34,7 @@ int main(int argc, char *argv[]) { application.setOrganizationName("akr"); application.setApplicationName("MetaTerm"); - engine.rootContext()->setContextProperty("workingDirectory", &directory); + engine.rootContext()->setContextProperty("cwd", &directory); QObject::connect( static_cast<QObject*>(&engine), diff --git a/src/command/commands.js b/src/command/commands.js index 2ec1bb6..13bb1c2 100644 --- a/src/command/commands.js +++ b/src/command/commands.js @@ -115,12 +115,12 @@ function q() { Qt.quit(); } -function cd(output, path) { - if ( path.length > 0 ) { - if ( !workingDirectory.cd(path) ) { - output.error('\"' + path + '\" doesn\'t exist.'); - } +function pwd(output) { + var terminal = terminalList.getCurrent().terminal; + + if ( terminal !== null ) { + output.log(cwd.currentOfPID(terminal.getPID())); } else { - output.log(workingDirectory.current()); + output.error('No running session selected.'); } } diff --git a/src/widget/EmbeddedTerminal.qml b/src/widget/EmbeddedTerminal.qml index 8a326ef..67d9a91 100644 --- a/src/widget/EmbeddedTerminal.qml +++ b/src/widget/EmbeddedTerminal.qml @@ -12,12 +12,13 @@ Item { property int lines : settings.terminal.initialLines property alias history : session.history + function getPID() { return session.getShellPID() } + function terminate() { return session.sendSignal(15) } + function select() { highlighter.select() } function deselect() { highlighter.deselect() } function displayOverlay() { overlay.displayBriefly() } - function terminate() { return session.sendSignal(15) } - height: terminal.height width: parent.width - settings.terminal.frameWidth |