How to edit fishshell startup script - fish

I am on arch linux and have installed the fish shell together with oh-my-fish
Can someone tell me which file i edit to add my custom shell startup commands
im zsh it was the ~.zshrc what is it in fish shell ?
i have a problem, if i put my stuff in bashrc it is not loaded by fish, if i enter shell comands in the fish file ~/.config/fish/config.fish it throws errors

Did you read Archwiki ?
~/.config/fish/config.fish

Related

Is there a reason the command 'mongo' works in VSCode terminal but not iTerm2 zsh terminal?

I just installed oh-my-zsh on iTerm2 and have been working on a project with MongoDB/node.
Now when I try to start the db with command 'mongo' I get a return 'zsh: command not found: mongo'
the command works perfectly fine in the built-in terminal for VSCode.
would like to be able to use iTerm exclusively instead of the vscode terminal.
Go to VSCode terminal and execute:
echo "$PATH"
Check where the mongo binary is located:
which mongo
brew info mongo
Go to your zsh and add to your .zshrc file the path where mongo is located:
export PATH="$PATH:/opt/homebrew/bin"
If you do not add the path you will still be able to run it like:
/opt/homebrew/bin/mongo
I'm not sure why, but when I went directly into the .zshrc file and added this line
export PATH="$PATH:/opt/homebrew/bin"
the command 'mongo' still didn't start the db.
BUT..
I figured it out. Instead of opening my .zshrc and editing it I just edited my path with this little line here with the path described by R2D2
path+=/opt/homebrew/bin/
Command 'mongo' is working perfectly now!

How to load .bashrc when using wsl interoperability?

I've downloaded neovim 5.1 and made a symlink to it in .local/bin folder.
After that I've added it to $PATH through .bashrc and aliased to vim:
alias vim="nvim"
export PATH=$HOME/.local/bin:$PATH
If I use vim command from inside the wsl I successfully launch neovim 5.1. However if I instead try to launch vim from powershell (wsl vim) .bashrc is ignored and vim 8.1 is launched instead. How can I make Powershell to use .bashrc in interoperability mode?
wsl bash -ic vim
-i tells bash that the shell is interactive, which causes ~/.bashrc to be loaded.
-c cause the next argument to be executed as a command(s); it also causes the bash process to exit after command execution.

Run a virtual environment globally?

Is there any way to make workon global? For example; I open terminal and type workon myenvname --global, then I open another terminal window and type something like python myscript.py and it will run it under the myenvname environment?
Also I can then open Sublime Text IDE and create a python script, then press CTRL+b and the python script will run in the myenvname environment.
Is such a thing possible?
No. Virtual environments must be activated in every shell (i.e., every terminal) separately.
There is no magic in Python virtual environments. Their activation just sets a few environment variables; the most important is PATH so that the current shell finds python and pip. Then python being run from a virtual env detects it and sets sys.path accordingly.
To some extent you can do a trick without activation: run python from a virtual env:
/path/to/venv/bin/python myscript.py
Hope it helps someone
You may not be able to run it globally but if you want to run a particular python script without entering into the virtualenv. Here's a work around.
Considering you are using this on linux.
Say you have a virtualenv called myenvname
You would like to run a particular python script myscript.py inside this particular myenvname without even using terminal by just double click on an icon.
Create a shell script myshellscript.sh
#!/bin/bash
# open the virtual environment
source /home/usr_name/.virtualenvs/myenvname
# location to the python script you want to run
# python/python3 depending on the version you are using
python location/to/your/python/script/myscript.py
Give permission for myshellscript.sh to be an executable
chmod +x myshellscript.sh
Create a .desktop file inside /usr/share/applications/
sudo nano /usr/share/applications/myscript.desktop
copy paste the block of code and make the changes accordingly
[Desktop Entry]
Version=1.0
Type=Application
Terminal=false
Exec=shellscript file to be run along with its path
Path=directory where the file is located
Name=myscript
Comment=comment here
Icon=icon path here
then give permission to the myscript.desktop
chmod +x /usr/share/applications/myscript.desktop
You are done.
Just goto /usr/share/applications/ and double click on myscript icon, you got your myscript.py running

How to add mongo commands to PATH on Mac OSX

I'm using MongoDb 2.6.1 following the material from https://university.mongodb.com/ (great material by the way) but I am not being able to add to my path the mongo commands.
I've followed this guide http://docs.mongodb.org/manual/tutorial/install-mongodb-on-os-x/ and I modified my .bashrc like this
export PATH=/Users/jonathancaballero/bin/mongodb/mongodb_2.6.1/bin:$PATH
And there is indeed where the binaries are (checked using the finder directly)
So my question is why I am not able to use mongod from any location in my terminal?
Please put the PATH export into .bash_profile:
export PATH=/path/to/your/mongo/bin:$PATH
Edit: The reason to put it into .bash_profile is that this file will usually get executed when bash is started as a login shell while .bashrc usually is exectuted for interactive non-login-shells. What usually happens is that .bashrc gets sourced in .bash_profile. This does not seem to be the case here. On MacOS X when you start a Terminal, .bashrc does not get executed. God knows why, as the shell opened should be an interactive non-login shell and therefor should execute .bashrc.
Another, albeit more "intrusive" solution would be to add the following to .bash_profile.
if [ -f ~/.bashrc ]; then
source ~/.bashrc
fi
For those who are interested in the details: take a look into the according sections of bash's manpage

Configure Eclipse to use bash login shell for Cygwin toolchain

I have a custom Makefile project in Eclipse and although the build does get run in a Cygwin shell... it does not seem to be a login shell (bash --login) as it doesn't set my environment variables like running cygwin.bat does.
Where in Eclipse can I change the shell command so that it will be a login shell?
What you actually aim with bash --login are your settings from /etc/profile.
Under UNIX you normally have only one login shell and so these settings are inherited by all other shells. Under Windows any Bash window is an isoloated login shell, which leads to missing environment settings when running Bash from tools that run bash simply as command processor.
I had a similar problem with Emacs compile feature. The best solution under Windows is to set the environment variable BASH_ENV to a script. Bash will execute this script when started without -i or --login, so that /etc/profile is not run. Hence the script will setup Bash for non-interactive, non-login shells.
Example:
BASH_ENV=%USERPROFILE%\.bash_env
as user environment variable. The least thing to do in this script is to set PATH as in /etc/profile:
PATH="/usr/local/bin:/usr/bin:${PATH}"
Check the path-settings in /etc/profile as it is created by Cygwin's setup.exe. You may also copy settings from ~/.bashrc or source this script.
Hope this helps.