How to set the $PATH for kitty terminal MacOS? - macos

I've been using iTerm2 on my Macbook Pro, but now I`ve just installed Kitty. After writing a few configurations into the Kitty config file, I noticed that, I can't use homebrew (zsh: command not found: brew) but however with iTerm2 I can use it as usual. I recognized that the $path variable is different for the Kitty terminal and the homebrew bin files folder doesn't appear, but if I check the $path with iTerm2, I can see the homebrew path into the $Path. In addition, the aliases I've got defined into the .zshrc file also don't work with Kitty but yes with iTerm2.
So my question is, why do Kitties have a different $path ? and what must I do to Kitty take the correct $path ?

After restart the kitty.config file the problem solved, so I reviewed this config file and the problem seems to be the shell directive, which was set to zsh. I don't know if we have to specify the absolute path to the zsh shell or whatever, but i deleted this directive and then kitty takes the default shell (zsh in my case) and the problem has been solved.

Related

How do programs add to $PATH variable with using .bash_profile?

How do some programs seem to add to the $PATH variable without using a .bash_profile file? What are the advantages to these approaches of adding to $PATH variable, but not using a .bash_profile file?
For my mac
echo $PATH returns
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/TeX/texbin:/Library/Apple/usr/bin
which java returns
/usr/bin/java
which tex returns
/Library/TeX/texbin/tex
How is Java available in the terminal without being in the $PATH variable? (This is an example of something running in the terminal without being in the $PATH variable.)
How did TeX add to the PATH variable without using a .bash_profile file?
What added Library/Apple/usr/bin to the PATH variable? Wikipedia says that only the first three are defaults: /bin, /usr/bin, and /usr/local/bin.
Note: Other StackOverflow posts helped users create a .bash_profile file (a file that doesn't exist by default on a Mac) to run programs such as android and adb when they received -bash: android: command not found
My question is about how the terminal works (like how java is running without being on $PATH) and how other programs (like TeX) added to $PATH without using a file like .bash_profile.
I am running macOS 10.15.5, confirmed that I do not have a .bash_profile file, do have homebrew installed (not sure if that affects anything) and when I open a terminal, it says "The default interactive shell is now zsh." (I think I installed zsh after reading a different StackOverflow a few weeks back.

Terminal doesn't work (bash commands aren't recognizable)

I have macOS Sierra version 10.12.6
I tried to add a path using the terminal. I entered source ~/.bash_profile and then a text file opened and I entered my path.
But then the terminal stopped responding and bash commands are not recognizable anymore.
If I enter: source ~/.bash_profile nothing happens.
And if I enter any environment related command an error message shows: -bash: printenv: command not found
How can I fix this?
You've probably messed up your path. When you're setting a path it's important to append to it rather than overwrite, or you lose access to all the system paths; /usr/local/sbin, /usr/local/bin, /usr/sbin etc. When setting a new path make sure you use:
$PATH=$PATH:/path/to/add
You can fix this by removing the line from .bash_profile where you overwrote the path. Please paste the contents of .bash_profile if this does not work.
You've replaced $PATH with some of your values and you might not be able to update .bash_profile because of the unavailability of nano. Use the following command to access nano and environment variables.
export PATH="/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin"
After using the command you can use nano ~/.bash_profile to fix the problem.

Set path to applications for vim on mac capitan

I have used vim to make small scripts in python and typesetting things in LaTeX. So it is very useful to run applications from vim by typing :!python or :!pdflatex etcetera. But after upgrading to el capitan, this seems not to work anymore, get message like /bin/bash: pdflatex: command not found. But the funny thing is that it is possible to run the applications directly from terminal. Anyone that know how to set the correct that for vim as well?
$PATH variable not properly set in gvim/MacVim when it is opened from the finder
first check :!echo $SHELL and see if SHELL is set to bash or not
then try to set your path in your ~/.bash_profile?
export PATH=<dir_contains_pdflatex>:$PATH

Setting environment variables in Yosemite

What is the proper way to modify environment variables like PATH in Yosemite?
This is this question Setting environment variables in OS X? but specifically for yosemite since it doesn't work anymore.
Have you tried editing ~/.bash_profile?
Adding a line like this to bash_profile ought to do it:
export PATH=/usr/local/bin:$PATH
What shell are you using? I'm assuming you're using the default Bash shell. There's also Csh, Ksh, and Zsh.
The Terminal.app on Mac OS X by default starts a new login shell each time a window is open. This means that $HOME/.bash_profile or $HOME/profile is always executed when you open a new terminal window. You can set particular defaults in here. For example, I set PS1 and set -o vi.
NOTE: This may not be the case if you're using other Terminal apps like xterm. These open new terminal windows as just new shells. This means that you may not see the changes made in .bash_profile until you log out and log back in.
You can try editing $HOME/.bashrc and see if that helps.
What about other shells?
If you're using Kornshell (ksh), you need to edit the $HOME/profile and not $HOME/.bash_profile. If you're using Zshell (zsh), you're on your own. It's too wacky to describe here. Read the manpage for zsh and search for ZDOTDIR.
When you run a shell script, the $HOME/.bashrc is executed. Most people put something like this in their .bash_profile, so their .bashrc settings are included in a new terminal window:
[[ -x $HOME/.bashrc ]] && source "$HOME/.bashrc"
Some people set things they want to be set when they run a shell script, for example export $PS4="\$LINENO> ".
The $PATH is a bit different. You can set it in .bash_profile (I would not set it in .bashrc), But, Mac OS X has an automated why on how systemwide paths are set. A file called /etc/paths is used to set the default path for all users using either Bash or Kornshell via the /usr/libexec/path_helper program.
On my Mac, I set my $PATH to:
/usr/local/bin:/usr/share/bin:/bin:/usr/bin:/usr/sbin:/sbin:$HOME/bin
When I install programs, I usually install them under /opt when possible. Then, I link their binaries (where ever they're placed) to /usr/local/bin. This way, I don't have to keep building my PATH. Plus, it allows me to override system defaults. For example, /usr/bin/git is at 1.9.3. while my installed /usr/local/bin/git is at version 2.2.1.
One thing you should not do is modify /etc/profile because changes there may be replaced on OS X upgrades.
The problem is not with environment variables set and accessed from within /bin/bash or /bin/sh, but with envars that should be set for programs NOT executed from the shell; i.e. normal apps executed from the dock or Finder.
After finally getting things right with launchctl in Mavericks, Apple is in the process of changing things again. The useful subcommands of launchctl are now labelled as "legacy subcommands", some of which are no longer supported. That leaves a question mark over the others.
In any case, the most important subcommands are still available for now.
launchctl allows for the setting of the overall environment in which user processes execute. It appears that the overall user environment is inherited by all Terminal processes; i.e. all setenv variables are exported. It's a bit tricky to confirm that. In any case, you will still need your .profile and .bashrc to define functions and aliases, which are not supported by launchctl.
I go to some lengths to ensure that all of my launchctl vars are also defined in my profile. This enables me to set up the same environment on remote or VM linux systems, with a few minor tweaks.
Al of my setup is described in this blog post .
following solution worked for me.
Open Terminal
Click on Terminal Menu at right upper corner.
click on Preferences
Click on General
Change Shell open with to command and put /bin/bash in text box.
Now whatever configuration you do in ~/.bash_profile takes effect. Previously you were not using bash(were using ksh) that is why it was not reading .bash_profile.

How to use correct ruby in vim ? How to modify $PATH in VIM?

I use plain Vim with ruby support on Lion (installed by gist). I am using ruby with rbenv so my path looks like /users/me/.rbenv/shims:.....
From within vim the path is
:!echo $PATH
> usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/fb/.rbenv/shims:....
Even I can create and modify an environment variable:
:let $PATH = "/bar:/foo"
:!echo $PATH
> /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/foo:/bar
paths remains starting with /usr/bin.
So how can I access my ruby 1.9.3 in ~/.rbenv/shims instead the system ruby in /usr/bin ?
This is a known problem introduced by Apple in OS X 10.5 Leopard.
If you are using Bash or Zsh and are using non-interactive shells, you are affected.
Running sudo chmod ugo-x /usr/libexec/path_helper will fix you up, but you should take a look at the article to see why.
rvm also has this problem. If zsh is your default shell when it starts /etc/zshenv gets executed.
This executes /usr/libexec/path_helper. That sets up the path based on the contents /etc/paths and /etc/paths.d/.
The faq for rvm mentions moving /etc/zshenv to /zsh/zshrc. I did this and it removed the /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin from the start of my path in macvim.
I did'n t set the shell option in .vimrc, so that it was automatically set to /bin/zsh.
Then I found out that I hab a dublicate initialisation of rbenv: in my .zshrc. I removed the initialisation end $PATH extensioin in .zshrc because that was already handled by the oh-my-zsh rbenv plugin.
Even after that cleanup, the $PATH mangeling still happening so :!echo $PATH
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/Users/fb/.rbenv/shims:/Users/fb/.rbenv/bin:/Users/fb/bin:/usr/local/sbin:/usr/games
Setting :set shell=/bin/bash was what helped me, as i can live with bash in my vim: :!echo $PATH
/Users/fb/.rbenv/shims:/Users/fb/.rbenv/bin:/Users/fb/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/Users/fb/Dropbox/local/bash
In your ~/.bashrc (or whatever shell you're using) file, add the following line:
PATH=/home/me/.rbenv/shims:${PATH}
and then run source ~/.bashrc (or .zshrc or whatever shell you're using!)
This can be fixed by just adding
PATH=/home/me/.rbenv/shims:${PATH}
to
/etc/zshenv
I don't use mac or zsh (I am on linux), however I ran into this problem when I ran gvim from the MATE Menu.
I solved it by adding this to my .vimrc:
if $PATH !~ "\.rbenv"
let $PATH="/home/username/.rbenv/shims:/home/username/.rbenv/bin:" . $PATH
endif
This avoids setting it if you run vim from a terminal, otherwise the rbenv paths would be included twice.
I tried setting the application to run via a terminal, but that didn't help.
yes on OS X it's the bash_profile that gets sourced when opening a new console window whereas on Linux it's your bashrc

Resources