Can't set title for terminal window when launched from Gnome menu launcher - redhat

I added a new Gnome menu option to launch a custom script application. I am using Redhat 6, Gnome 2. This is all working but when it launches in a new terminal window I cannot get the title to display anything other than the default 'Terminal'.
Here's how I have it configured; I have added the following files to get it working:
/usr/shared/applications/app.desktop ( configures launching of my application )
/usr/shared/desktop-directories/app.directory (specify a directory from menu for my app)
/etc/xdg/menu/application-merged/app.menu ( adds menu option to main Applications pull down menu)
The app.desktop file specifies the location of the script I want to run and I have set the 'Terminal' option to 'True' which launches it in a new terminal window. I have tried adding the following to during startup of the script but it doesn't change the title.
PROMPT_COMMAND='echo -ne "\033]0; APP TITLE\007"'
Setting the 'PROMPT_COMMAND' from a separate, interactive terminal DOES work though. Not sure why it doesn't work when launching from the gnome application launcher.

As far as I know, you can't really set the terminal window title I have tried everything even modifying files but to no avail. The method which your using is meant to be put in the .bashrc in the home folder but doesn't seem to work.
gnome-terminal --title="example"
The command above which I have tried doesn't work either

Related

Angular ng serve asking to open app and not working

Problem Statement
When I try to do ng s -o in my terminal for my Angular app, it says, "How would you like to open this?" inside a popup box where I can choose an app, but choosing an app doesn't work.
Image of Problem
When I try to choose an app, it displays code. When I chose Chrome in the popup box, this happens:
The image shows that when I run an app after ng s -o it just displays code. Also, the tab title in the browser says "ng" when the code shows. Another thing, there is no error in the terminal...
Expected Results
I want to run my Angular app with ng s -o.
Actual Results
The app doesn't serve and asks to open an app.
Note: I am using Visual Studio Code for this.
The problem was related to my cli. I was using PowerShell when I was running ng, and for some strange reason, PowerShell stopped running ng and was asking me to open an app to run the file. Even though this never happened to me before and I was using ng and PowerShell just fine before. Strange!
Now I am using CMD instead. It now runs perfectly. So, I switched cli's from PowerShell to CMD in my integrated terminal in Visual Studio Code and it started working.
I got the idea to switch cli's from this: https://github.com/Microsoft/vscode/issues/28541
npx ng serve -o works for me in visual studio code.
The problem was caused as the Vs code was using PowerShell mode. By changing it to default cmd mode, the ng commands started to work.
The steps to change from PowerShell to cmd mode is as follows:
Press Ctrl + Shift + P to show all commands.
Type profile in the displayed text box to filter the list.
Select Terminal: Select Default Profile.
You will be prompted to select your preferred terminal shell, you can change this later in your settings or follow the same process as we do now.

vscode automatically "source activate" everytime launches new terminal

Recently when I'm using vscode, everytime I launches the built-in terminal, it automatically uses "source activate base" to launch a anaconda python virtual environment. You can see the screenshot
I don't think I changed anything but it just came up randomly. Can someone help me out?
To prevent automatic activation of a selected environment, add
"python.terminal.activateEnvironment": false
to your settings.json file (it can be placed anywhere as a sibling to the existing settings). However, debugging or running Python code without any activated environment won't work.

How do I open a new terminal tab in my VScode extension? (split terminal)

I am creating a simple VScode extension which opens a number of terminal tabs and runs small snippets of code (to run dev server and client dev environment)
I would like to be able to open a new terminal in a terminal tab, in the same way that the 'split terminal' functionality works in the main editor
Currently I can create a new terminal using:
vscode.window.createTerminal(`New termainal name`)
However this creates a new terminal, whereas I would like to able to add a new tab to the current terminal in the same way as the 'Split terminal' button.
I am using the extension sample at https://github.com/Microsoft/vscode-extension-samples/blob/master/terminal-sample/src/extension.ts
Thanks! M
It looks like this is currently not supported, but planned:
Add an API for splitting a terminal (#45407)

Prevent integrated terminal from opening automatically

Whenever I open a PowerShell script in VS Code, the integrated terminal opens. How can we prevent the integrated terminal from opening automatically. I have searched the settings for "terminal" and have found nothing associated with auto-start.
VSCode will remember your last session.
So, if you close the terminal and exit VSCode, the next time you open, the terminal will not be displayed.
You can set your VSCode profile to not display (close the terminal on load).
As for User Settings:
This is not the first time this has been asked for.
https://github.com/PowerShell/vscode-powershell/issues/580
powershell.startAutomatically: When set to true (default), causes the
language service to start automatically the first time a PowerShell
file is opened. You could then use the "Restart PowerShell Session"
command to kick off the language service on demand. •
powershell.showIntegratedConsoleOnStartup: When set to true (default),
causes the integrated console window to be shown automatically when
the language service starts. If false, the language service starts but
the console window isn't shown until the user runs script code (or
runs the Show Integrated Console command)
Update as per the OP side discussion with me
What I just tested.
In your custom user settings, either set the:
"powershell.enableProfileLoading": false
or if you have that setting this way:
"powershell.enableProfileLoading": true
Add this setting:
"powershell.integratedConsole.showOnStartup": false,
What Worked
"powershell.integratedConsole.showOnStartup": false
If the setting isn't there yet, then simply add it.
What Almost Worked
Setting "powershell.startAutomatically": false also kills the entire PowerShell extension.
Relying on VSCode to remember the last session's setup works inconsistently; for instance, it does not work when loading a file directly from a terminal with $ code someFile.psm1.
I believe the setting is:
"terminal.integrated.enablePersistentSessions": false
regardless of Powershell or other types of terminals. This should be self-explanatory.
My VSCode v1.65.2
File->Preferences->Settings
In the Search settings input field:
Type the word-> terminal
Under Extensions:
Click-> Remote-SSH
Uncheck-> Always reveal the SSH login Terminal.
Close all VSCode windows and restart VSCode.
Open the remote SSH location and the integrated terminal should no longer open automatically.

Launch mac eclipse with environment variables set

My company provides an eclipse based development environment which needs some environment variables setting up for the underlying toolchain so multiple versions can be installed concurrently and not take over the system.
I want to provide an icon in finder or the dock which sets these then launches eclipse so customers cannot accidentally launch eclipse without the environment being set. This is what I have tried so far:
Setting environment in Info.plist
for eclipse:
This should be a nice way to do it
but I cannot make it add to the
existing path (like export
PATH=/myapp/bin:$PATH).
bash script wrapping eclipse:
I created a bash script called
eclipse.command to set the
environment then launch eclipse.
This opens a terminal window as well
as the eclipse icon and allows
people to "Keep on dock" for the
bare eclipse. I cannot put
eclipse.command on the dock as it is
not an application.
Applescript wrapping eclipse.command:
An Applescript wrapper around
eclipse.command makes it look like
an app and prevents the terminal
window appearing. Unfortunately I
now get a dock icon for the
applescript and one for eclipse so
can still keep the bare eclipse on
the dock.
Any suggestions? Am I going about this in completely the wrong way?
There is an alternate solution which involves replacing the executable that is run by MacOS X when the user launches the Eclipse application with a shell wrapper that sets up the environment.
Create an empty text file called "eclipse.sh" in the Eclipse application bundle directory /Applications/eclipse/Eclipse.app/Contents/MacOS.
Open the eclipse.sh in a text editor an enter the following contents:
#!/bin/sh
export ENV_VAR1=value
export ENV_VAR2=value
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $#
In the example ENV_VAR1 and ENV_VAR2 are the environment variables being set up. These variables will be visible to processes launched from within Eclipse. The logger command will just log the path of the eclipse executable to the system.log as a debugging aid.
In the Terminal set the executable flag of the shell script eclipse.sh, i.e.:
chmod +x /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse.sh
Open the Eclipse.app Info.plist and change the value for the key CFBundleExecutable from eclipse to eclipse.sh.
MacOS X does not automatically detect that the Eclipse.app's Info.plist has changed. Therefore you need to force update the LaunchService database in the Terminal by using the lsregister command:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app
The next time you launch Eclipse.app from the Dock or from the Finder the environment variables should be set.
I created the following:
alias start-eclipse='open /Applications/eclipse/Eclipse.app'
If you run start-eclipse from the command line, all env vars will be picked up. This way, you only need to maintain a single set of env vars across both command-line and eclipse environments.
Take a look at a related question: Environment variables in Mac OS X.
Basically, this involves the creation of a ~/.MacOSX/environment.plist file.
Log out and Log in for the environment.plist to get picked up by .App's
This worked perfectly in OS X Yosemite:
Open /Applications/Automator.
When the drop-down appears asking you what kind of document you want to create, choose "Application."
In the second-from-the-left list, double-click "Run Shell Script."
In the right side delete the "cat" that gets put there automatically, and replace it with this:
source ~/.bash_profile && /Applications/eclipse/Eclipse.app/Contents/MacOS/eclipse
Now go to File->Save, and save the application to your Applications directory. I named it "Eclipse" with a capital 'E' so as not to conflict with the "eclipse" directory I already had. For good measure, you can even give it the Eclipse icon by selecting the real eclipse app, pressing command-i, selecting the icon, pressing command-c, then selecting the automator "Eclipse" app, pressing command-i, selecting the icon, and pressing command-v.
Now you can open the app, or even drag it to your dock. Note that if you start it, the "real" eclipse will still show up in your dock as a separate icon, but you can't have everything. :)
sakra's answer above is awesome, except is doesn't automatically inherit your existing bash environment. To ensure eclipse.sh picks up your existing bash environment, modify eclipse.sh to use bash instead of sh and add a line to source your existing ~/.bash_profile thus:
#!/bin/bash
source ~/.bash_profile
logger "`dirname \"$0\"`/eclipse"
exec "`dirname \"$0\"`/eclipse" $#
None of the above worked for me. you have to set Eclipse -> Preferences -> Terminal -> Arguments set to --login
That will instruct Eclipse to login with your account just after opening Terminal.
See screenshot:
Reference: https://marketplace.eclipse.org/comment/4259#comment-4259
Link to Eclipse doesn't use the path set in .bashrc
Create simple script
#!/bin/bash
source /home/user/.environment_variables
/home/user/eclipse_cpp/eclipse -Duser.name="My Name"
2.
Next put your all system variables in file /home/user/.environment_variables (any file you want)
My looks like:
export COCOS_ROOT=/home/user/Projects/edukoala
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/
3.
Now you can delete your variables in .bashrc and put line
source /home/user/.environment_variables
Everything works fine :)
As pointed out in https://github.com/atom/atom/issues/7045, the environment variables can be loaded automatically, without explicit source ~/.bash_profile by using
#!/usr/bin/env bash -l
instead of
#!/bin/bash
source ~/.bash_profile
after that, in both cases, follows
exec "`dirname \"$0\"`/eclipse" $#
It works great for me, thanks for all previous work.
After setting env variables in .bash_profile.
Simply open the application through terminal!
open /Application/{path/to/app}.app