How to automatically start fish shell in private mode? - fish

Thanks to the developers of Fish for making it possible to launch the shell in private mode :)
However, what am I supposed to add or change in the files fish_prompt.fish and/or config.fish in order to launch fish in private mode automatically when I open a new terminal window?
And if it is possible to launch fish in private mode automatically, is it possible afterwards to launch fish in public mode manually whenever it is necessary?
Thanks for your help!

"Private mode" is a commandline option to fish.
Instead of launching fish, start fish --private.
If you want to disable history after you have started fish, set the $fish_history variable to an empty value, i.e. set -g fish_history "". This can also be done in config.fish.

Related

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.

VS Code Terminal Not Allowing Typing

My VS code terminal was working fine, until one day when I tried to work on a project, that was still open in VS code, my terminal didn't allow me to type any commands. I couldn't type anything. This is the screen that I get.
Okay, for those of you struggling with the same problem, I've managed to solve it by clicking on the drop-down menu that says powershell and changing it to cmd.
this happened to me and simply
close vs code
right click on it
run as administrator
open the terminal and it will work
this problem happened when I changed the default path of CMD
For me, I tried using Powershell/CMD/Bash and I was having errors/blank terminal. I found typing echo hello and pressing CTRL + C made it appear. So in fact, everything was working, my terminal was just blank/glitched out, but was really accepting input.
I had a similar issue when running ionic serve command which runs the development server on the localhost. I paid attention after executing the command above, and it said:
Use Ctrl+C to quit this process
Pressing Ctrl+C then displays:
Terminate batch job (Y/N)?
Type Y or y
then the command prompt is shown again!
Here is a sample terminal window - trimmed for brevity:
For who has this problem using React. This happens when you start a live version using npm start. The terminal that handles the live version of the app cannot be used for anything else.
So to continue using the terminal you need to open a new terminal to use in parallel. To do so just click on the plus icon in the top right corner of the terminal panel then choose the "Power Shell" option. This will open a new terminal without restarting visual studio.
In Mac, when working with Python, this helped me: instead of clicking on the "Run Code" option, click on "Run Python file", in the right corner.
For Ubuntu users this is solved by this solution:
File -> Preferences -> Setting -> Features -> Terminal -> Inherit Env
I found two vscode on my desktop, I opened the other one and it worked. Looks like I updated it but the older one didn't disappear.
If typing Ctrl+C can help to get out of this frozen state, that will be easier to do with VSCode 1.64 (Jan. 2022)
The terminal can type the answer for you.
Terminal -- Auto-reply
The terminal is now able to automatically reply when a specific sequences of characters is received.
A good example of where this is useful, which is also the only default case, is the Windows batch script message Terminate batch job (Y/N)? after hitting Ctrl+C when running a batch script.
This typically just ends up causing problems for the user.
The terminal will now automatically reply with Y and enter (\r) which makes Ctrl+C in Windows feel much better.
Pressing Ctrl+C will immediately reply to the question and return to the prompt:
Theme: Sapphire
The feature was made generically so you can setup custom replies for other thing, just be careful when doing this as you are sending text to the process automatically.
For example you could use it to automatically update Oh My Zsh when prompted:
"terminal.integrated.autoReplies": {
"[Oh My Zsh] Would you like to check for updates? [Y/n]": "Y\r"
}
If you use Clink and enable their similar feature, you can disable it in Clink or in VS Code by setting the reply to null to avoid the two features conflicting with each other:
"terminal.integrated.autoReplies": {
"Terminate batch job (Y/N)": null
}
Go to terminal, preferences, settings.
Check "run code in terminal"
Restart VS.
I changed from bash to powershell in terminal first but the command prompt still not shown.
Then I navigate to File -> Perferences -> Settings and it starts working (command prompt shown)
This seems to just be a display problem. It happened to me when I changed my display settings for desktop icon and app scaling settings.
I managed to fix the problem by simply restarting my computer and re-opening VS code
I had the same problem ... In my case just run vs-code as administrator and works

Emacs term pastes strange line into terminal when changing directories

I am using fish terminal inside of Emacs term
My normal prompt on load looks like the following
Welcome to fish, the friendly interactive shell
Type help for instructions on how to use fish
$>
Ok, when I load fish term inside of term.el it looks like this
Welcome to fish, the friendly interactive shell
Type helpB for instructions on how to use fish
7;file://Collins-MacBook-Air.local/Users/collinbell/Programs/riddley⏎
$>
A cd command in my normal terminal looks like this
$> cd ~/
$>
However in the emacs term.el it looks like this
$> cd ~/
7;file://Collins-MacBook-Air.local/Users/collinbell⏎
$>
I have no idea why it is pasting the cwd into the buffer, but it does it every time a directory changes. Emacs also makes the system sound after this, while other commands like ls do not make the system sound.
This is obviously not the biggest issue in the world, but I do run clear as a pre-command to keep my terminal looking clean (although I turned it off for this example) and Emacs pasting this line into the buffer really messes with sublime usage.
You seem to be experiencing a known issue.
Try this fix:
In your fish config file ~/.config/fish/config.fish add the following:
function fish_title
true
end
Also, see this from the fish documentation, though according to the github issue, the fix suggested in the docs might not work, while the above function does.
According to the fish documentation, this is what's going on:
Fish is trying to set the titlebar message of your terminal. While
screen itself supports this feature, your terminal does not.
Unfortunately, when the underlying terminal doesn't support setting
the titlebar, screen simply passes through the escape codes and text
to the underlying terminal instead of ignoring them. It is impossible
detect and resolve this problem from inside fish since fish has no way
of knowing what the underlying terminal type is. For now, the only way
to fix this is to unset the titlebar message, as suggested above.

Make emacs run in console mode (-nw) by default

How can I make Emacs run in terminal (or console) mode by default, as if I'd used -nw? And once that's done, how do I force it to run in GUI mode (once) if I need to?
On my Debian testing, alias emacs='emacs -nw' followed by emacs opens Emacs in the terminal. And, in the same session, emacs23-x opens Emacs with the GUI.
In case you decide to use emacs in terminal mode always, install emacs-nox (emacs with no X support).
After installationis still ran by $ emacs so you no need to create aliases again!:)
Its there in repos of Debian Squeeze so must be in Ubuntu also.
This answer suggests the method I found works best for me (was having problems with aliases). Essentially, create an executable script
#!/bin/sh
emacs -nw "$#"
and point $EDITOR to it in your shell rc file.
I ran into this problem and didn't want to set an alias (because I also wanted "emacs -nw" to be my default shell EDITOR but it wouldn't work) so I started grepping around and saw this line in configure
If you are sure you want Emacs compiled without X window support, pass
--without-x to configure.
So, if you want to download and build from source, you can just do
curl http://gnu.mirrors.hoobly.com/emacs/emacs-25.3.tar.xz
tar -xvzf emacs-25.3.tar.xz && cd emacs-25.3
./configure --without-x
make && sudo make install
alias emacs='emacs -nw'
Or
unset DISPLAY

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