1

I used this to make it so Byobu runs on terminal startup. However, when I open an embedded terminal in IntelliJ, it does the same and uses the same buffer. This results in the embedded terminal looking like this: enter image description here

And my regular terminal looks like this: llij

The text and size of the viewable area are identical regardless of which you modify, so they're definitely using the same buffer.

Is there a way to make it so the embedded terminal in IntelliJ doesn't open Byobu? Maybe some sort of condition on the line setting _byobu_sourced that checks the entity that is calling it?

EDIT: This technically belongs in AskDifferent because I'm doing this on a Mac, but the idea still applies to both Ubuntu and Mac. Furthermore, users here on AskUbuntu are more likely to encounter this issue since Byobu is used by many more Ubuntu users than Mac OS users. Because of this difference, your situation may slightly differ.

1 Answer 1

0

My solution below only worked in some instances. However, I found that IntelliJ makes a local variable in jediterm-bash.in named __INTELLIJ_COMMAND_HISTFILE__ when creating a new shell. Appending the following in .bashrc or .bash_profile for Ubuntu and Mac respectively yields the desired results:

if [[ -z "$(env | grep __INTELLIJ_COMMAND_HISTFILE__)" ]]; then
    _byobu_sourced=1 . /usr/local/Cellar/byobu/5.129/bin/byobu-launch 2>/dev/null || true
fi

Old Answer:

A solution I found was to capture the pid of the process that is currently sourcing my .bashrc. I use that and compare it to what I determine to be my open terminal's shell pid to conditionally execute the _byobu_sourced line. This is how it looks for me:

intellij_pid=$(ps | grep 'bash' | grep 'IntelliJ' | awk '{print $1}' | head -n 1)
bash_pid=$(ps | grep '/bin/bash' | grep -v 'color' | grep -v 'IntelliJ'| awk '{print $1}' | head -n 1)

# if we're spawning a regular shell then connect to byobu, otherwise it's probably intellij or some other process so open a normal shell
if [[ "$$" == "$bash_pid" ]]; then
    echo "byobu shell sourcing"
    _byobu_sourced=1 . /usr/local/Cellar/byobu/5.129/bin/byobu-launch 2>/dev/null || true
elif    [[ "$$" == "$intellij_pid" ]]; then
    echo "IntelliJ shell spawning"
else
    echo "some other shell spawning?"
fi

The result is only running byobu in my regular terminal, skipping the line when the sourcing process is IntelliJ or any other process

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.