Commit 464a9fdf authored by Matan Ziv-Av's avatar Matan Ziv-Av Committed by Tomaz Canabrava
Browse files

Add action to setup semantic shell integration in bash

Default shortcut: ctrl-alt-]
parent ccd56f20
Pipeline #203462 passed with stage
in 5 minutes and 2 seconds
......@@ -274,6 +274,12 @@ void ViewManager::setupActions()
_multiTabOnlyActions << action;
_viewContainer->addAction(action);
action = new QAction(i18nc("@action Shortcut entry", "Setup semantic integration (bash)"), this);
collection->addAction(QStringLiteral("semantic-setup-bash"), action);
collection->setDefaultShortcut(action, Qt::CTRL | Qt::ALT | Qt::Key_BracketRight);
connect(action, &QAction::triggered, this, &ViewManager::semanticSetupBash);
_viewContainer->addAction(action);
action = new QAction(this);
action->setText(i18nc("@action:inmenu", "Equal size to all views"));
collection->setDefaultShortcut(action, Konsole::ACCEL | Qt::SHIFT | Qt::Key_Backslash);
......@@ -470,6 +476,22 @@ void ViewManager::detachTab(int tabIdx)
Q_EMIT terminalsDetached(splitter, detachedSessions);
}
void ViewManager::semanticSetupBash()
{
int currentSessionId = currentSession();
// At least one display/session exists if we are splitting
Q_ASSERT(currentSessionId >= 0);
Session *activeSession = SessionManager::instance()->idToSession(currentSessionId);
Q_ASSERT(activeSession);
activeSession->sendTextToTerminal(QStringLiteral(R"(if [[ ! $PS1 =~ 133 ]] ; then
PS1='\[\e]133;L\a\]\[\e]133;A\a\]'$PS1'\[\e]133;B\a\]' ;
PS2='\[\e]133;A\a\]'$PS2'\[\e]133;B\a\]' ;
PS0='\[\e]133;C\a\]' ; fi)"),
QChar());
}
QHash<TerminalDisplay *, Session *> ViewManager::forgetAll(ViewSplitter *splitter)
{
splitter->setParent(nullptr);
......
......@@ -399,6 +399,8 @@ private Q_SLOTS:
/* Detaches the tab at index tabIdx */
void detachTab(int tabIdx);
void semanticSetupBash();
private:
Q_DISABLE_COPY(ViewManager)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment