Can't find .zshrc file - macos

Recently I installed someone else .dotfiles and as excepted overwrited my configuration.
The thing is that I want to use my custom settings for my ZSH but I can't find .zshrc inside ~/, I have other .zshrc.files but editing none of these is working.
Also the dotfiles I've installed are in `~/.dotfiles but seems that none of these contains config.
Can someone please explain me how to edit the ZSH now, can I revert my old .zshrc?

Go to home directory typing cd
Type the command zsh and Press Enter
Select the option (2) Populate your ~/.zshrc with the configuration
recommended
by the system administrator and exit (you will need to edit
the file by hand, if so desired).
(You have to type "2" to select it and press enter)...
then all the files will be created on the directory..

Related

Mac Terminal Prompt of iTerm with Oh-my-Z is messed up

I'm not sure exactly what I did besides try to uninstall an application but it seems my prompt is not working. I just want my iTerm 2 back to the way it was...
Here is my .zshrc file and the prompt. It looks bad. How do I fix this?
It looks like you are using Oh-My-ZSH. In that case you should be able to restore at least the default settings with:
cp $HOME/.oh-my-zsh/templates/zshrc.zsh-template $HOME/.zshrc
This will of course overwrite your ~/.zshrc, but the first line is in the template anyway and the second line is a bash-styile definition for the shell prompt and has no place in a zsh configuration file.
After copying the template I would suggest having a look into the new ~/.zshrc to see, if there are any other settings you want to make.
If the cp command fails because it cannot find the source file, then you probably have somehow removed Oh-My-ZSH. In that case you can re-install it by following the instructions on OhMyZ.sh.

Cant access my bash files

So I wanted to install MySQL on my MBP and I edited my bash_profile, added a path variable, however when I run echo $PATH from iTerm2 I get my path as:
Robs-MBP:~ Rob$ echo $PATH
/usr/local/mysql/bin
Ive tried a lot of commands and even used sudo and it just says command not found. My fear is that I have completely messed up, and now nothing works. Please help.
You've made a simple mistake: all you've done is reset the PATH env variable. To correctly do this, you should always add the existing PATH to the end of whatever you're adding. In you case:
PATH=/usr/local/mysql/bin:$PATH
To fix your problem from the terminal, you'll need to reset your PATH to somewhere with a text editor. I don't know where this is located on OSX, so you'll have to find it. After you know where your path should point, run:
$ export PATH=<YOUR_PATH_HERE>
Then edit your bashrc to include the original path as described above, and restart the terminal.
Alternatively, open .bashrc with a GUI text editor and make the change from there. Your PATH decleration should always end in :$PATH to include the PATH created by your system.

-bash: /Users/myname/.bash_profile: Permission denied

I installed rvm (ruby version manager) and it was success, but I got
WARNING: You have '~/.profile' file, you might want to load it, to do
that add the following line to '/Users/myname/.bash_profile': source
~/.profile
I am new to developing, terminals and all that jazz! But better late than never?!
I entered into terminal:
'/Users/myname/.bash_profile'
and got back the following line
-bash: /Users/myname/.bash_profile: Permission denied
myname-MacBook-Pro:~ myname$
And that is where I am stuck! I need vrm for Drupal (Omega development) and want to make sure that everything is working fine. Thanks for your help.
Enter the .bash_profile file by running this in your terminal:
vim ~/.bash_profile
If you still get permission denied, run sudo before the vim command
sudo vim ~/.bash_profile
From there , press insert button . then add the text source ~/.profile to .bash_profileand press esc and then hit :x on your keyboard to save and close the file. Opening a new terminal window should remove the error.
Entering a filename will try to execute it. Instead, you want to edit it.
Open TextEdit (or your favorite editor) and open the file /Users/myname/.bash_profile in it.
You can do this entirely through the UI, but if you want, you can start an editor from the terminal:
open -a TextEdit /Users/myname/.bash_profile
You can then add the line source ~/.profile to the file and save it.
Close the terminal and open it again to apply the changes.
In my issue when I try with ssh on server, I get this error :
-bash: /home/user/.bash_logout: Permission denied
for resolved your user home directory must has a execute permission.
chmod +x <user_home_directory>
you must relogin next. If you add .profile
export PATH+=:$HOME/bin
without .bash_profile as I do all time you'll insert ~/bin search dir not the end of PATH and in middle. So .profile call before local profile formed and some others system dirs will be added after. It's bad so priority for you home binaries will higher then some system one. And may change undesired behavior with same names. So you need to add PATH in .bash_profile, not to .profile It's guarantee to add your home bin dir at the end of PATH. But don't delete ~/.profile at all. It's need to add some other data. This file call once at first login and .bash_profile call every time when second login with su without -l and then return back. If don't bother You will get two home bin dirs in PATH, next tree and so on. It's not well. So you must correct like that:
p=:$HOME/bin && test `expr $PATH : '.*'"$p"` -gt 0 || export PATH+=$p || true
It's grantee that home bin dir will add only one independent how many times you login after change effective user with su and then return back.
true at end better write so if on some unpredictable reasons error occurs in
command export PATH+=$p(sometimes such occurs) your profile load stops and you can't login at all. It's grantee that this line will run with any error generate.

How to remove entry from $PATH on mac

I was trying to install Sencha Touch SDK tools 2.0.0 but could not run it properly. It created an entry in the $PATH variable.
Later I deleted the sencha sdk tools folder but didn't realize that the path variable is still there.
When i did echo $PATH I got -
/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
I searched on how to remove variables from $PATH and followed these steps :
Gave the command PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin"
Did echo $PATH which showed /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
gave the command export PATH
Closed terminal and reopened it. Gave the command echo $PATH. This time I got
/Applications/SenchaSDKTools-2.0.0-beta3:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin
Can anyone tell me what am i doing wrong?
echo $PATH and copy it's value
export PATH=""
export PATH="/path/you/want/to/keep"
Check the following files:
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
Some of these files may not exist, but they're the most likely ones to contain $PATH definitions.
On MAC OS X Leopard and higher
cd /etc/paths.d
There may be a text file in the above directory that contains the path you are trying to remove.
vim textfile //check and see what is in it when you are done looking type :q
//:q just quits, no saves
If its the one you want to remove do this
rm textfile //remove it, delete it
Here is a link to a site that has more info on it, even though it illustrates 'adding' the path. However, you may gain some insight.
What you're doing is valid for the current session (limited to the terminal that you're working in). You need to persist those changes. Consider adding commands in steps 1-3 above to your ${HOME}/.bashrc.
If you're removing the path for Python 3 specifically, I found it in ~/.zprofile and ~/.zshrc.
$PATH contains data that is referenced from actual files. Ergo, you should find the file containing the reference you want to delete, and then delete said reference.
Here is a good list to run through progressively [copied from #Ansgar's answer with minor updates].
/etc/bashrc
/etc/profile
~/.bashrc
~/.bash_profile
~/.profile
~/.MacOSX/environment.plist
/etc/paths
/etc/paths.d/
Note that /etc/paths.d/ is a directory that contains files with path references. For example, inside this directory may be a file called, say, fancy-app, and inside this file you'll see an entry like below:
/path/to/fancy-app
This path will appear in your $PATH and you can delete the entry in the file to remove it, or you can delete the file if it has only the one reference you want to remove.
Use sudo pico /etc/paths inside the terminal window and change the entries to the one you want to remove, then open a new terminal session.
when you login, or start a bash shell, environment variables are loaded/configured according to .bashrc, or .bash_profile. Whatever export you are doing, it's valid only for current session. so export PATH=/Applications/SenchaSDKTools-2.0.0-beta3:$PATH this command is getting executed each time you are opening a shell, you can override it, but again that's for the current session only. edit the .bashrc file to suite your need. If it's saying permission denied, perhaps the file is write-protected, a link to some other file (many organisations keep a master .bashrc file and gives each user a link of it to their home dir, you can copy the file instead of link and the start adding content to it)
Close the terminal(End the current session). Open it again.
If the manual export $PATH method does not seem to be working after you close the terminal and open again, definitely check the shell configuration files.
I found a small script that kept adding some more path in front of the $PATH everytime it was open.
For zsh you can check the ~/.zshrc file.

Vim Can't Save File (E212)

Sometimes when I create a file using vim some/path/newfile, vim lets me edit it, only to complain when I attempt to save my changes.
E212 Can't open file for writing.
This appears to happen only when the new file is located in a system directory.
:w! does not override this error.
How can I write the current buffer, without having to save it to a temporary location, exit, then rename it using sudo?
This will ask you for the root password, then save your changes as you requested:
:w !sudo tee %
Then type (L)oad at the prompt, to re-load the file after it is saved.
You can mkdir first, then save it.
Add this line to your .vimrc:
cmap w!! %!sudo tee > /dev/null
and then you can do
:w!!
when you get into this position, and it will write the file using sudo. Very handy.
You can avoid this problem by using "sudo" to start the editing session.
sudo vi name-of-file
If you want a robust, easy-to-remember solution and don't mind installing a plugin, try SudoEdit.vim - Edit Files using sudo or su or any other tool.
If this is the case in Windows 7 or later editions, run the VI editor as Administrator. Right Click of the application and select "Run as Administrator". This issue will be resolved. Moreover, the error is due to Administrative Privileges.
vim some/path/newfile
you can try to do it in two steps,first create the folder 'some' and 'path' by use mkdir ~ ;second you go into the 'path' folder,use the command:sudo vim newfile.then save it
Make sure the directory where you are trying to save the file exists and that you have permission to edit the file.
You can type :help message in Vim to get more information on this and other error messages. Try searching by typing /E212 once the docs come up. You can also view the documentation online at http://vimdoc.sourceforge.net/htmldoc/message.html and CTRL-F to find it.
For what it's worth, you may also want to ensure you have sufficient storage in the partition where you're attempting to save the file. I had to free up some space in my /home drive and that resolved the issue.
I know this is an old question, but this is what fixed it for me. Your file might be set to immutable meaning that you can't edit it.
You can check this with lsattr /path/to/file.txt
If it is use
chattr -i /etc/resolv.conf to make it no longer immutable.
Just had this issue outside of system directory.
When I tried to open a file vim src/help/tips.c. Turns out help directory did not exist, the directory was named differently and it was one of those very rare occasions that I did not auto-complete with Tab.
So, in conclusion, if this happens for a file that is not at a place where you may have permission issues, look if the path leading up to the file is a valid one.
I have experienced this in Kali!! The default account requires escalation to root with "sudo" in order for the file to be editable.
e.g: sudo vim / at this point all standard expectations appear to follow.

Resources