Accidentally deleted contents of .zshrc, can I get them back? - bash

I was trying to add sql to my zsh file and I ran this code I found online:
echo 'export PATH=${PATH}:/usr/local/mysql/bin/' >.zshrc
When I opened .zshrc, this was the only line in the file and everything I had before was deleted.
Can someone please help me in understanding if I can revert back to what I had before I made this change? Or is everything just lost now? And what about this line of code did this?
FYI, I'm using Mac. Also, things like commands like "brew" and "npm" are still working, despite my .zshrc being empty. I don't know if that's telling or helpful in any way. ("sql" still doesn't work)

Related

PATH related issues

A couple of days ago, I added code to my Mac's PATH to make some newly installed programs work properly on my machine. Unfortunately, it seems I have messed it up somewhere because some additional lines are printed every time I open my terminal.
Here is a screenshot of my terminal:
And here is a screenshot of my PATH Variable:
Does anyone know how I can remove extra lines in my terminal?
Thanks in advance
I renamed my ~/.zshrc file to ~/.zshrc2. Then all the extra lines were not shown anymore while opening up my terminal. Now I am sure the problems belong somewhere in my ~/.zshrc file
You can rename a folder by entering this command mv old-name-folder new-name-folder in the folder's directory.

issues running bash file from any directory

Not sure if this is operator error or if I just don't understand enough of what I am trying to do.
I have created cleardl.sh and put it in ~/bin and have also added ~/bin into $PATH, when I run echo $PATH it shows that it was added correctly.
If I am in ~/bin I can run ./cleardl.sh and it runs like it should, but if I try to run it from anywhere else I get a file not found error.
I have tried to make an alias for it but this also doesn't work more than likely due to me not knowing how to do that either.
Any help is appreciated.
Edit:
Moving the file to /usr/local/bin did get it working but then I deleted it to do some other tests and it kept working So it was likely me not having all the things correct at the same time.
Thanks for your help

zsh export path works when directly type in terminal, but not work when put in /.zshrc

I am frustrated on getting this to work... I am using zsh and from a tutorial it needs me to put these three lines in .zshrc in order to get android sdk to work
export ANDROID_HOME="$HOME/Library/Android-SDK"
export PATH="$HOME/Library/Android-SDK/tools:$PATH"
export PATH="$HOME/Library/Android-SDK/platform-tools:$PATH"
However, after I've done them, zsh always says
zsh: command not found: android
I've searched around Google and SO and found several posts asking the similar questions, so I've almost tried them all, like removing the double quotes, put $PATH to the front, removing export key word, etc, but none of them works for me. I've restarted iTerm and even my computer.
BUT, once I type them line by line in terminal directly, and then use android, it works!
What is the reason here? Or where should I really put them in for permanent effect?
Thanks guys.
As far as I know you need to tell .zsh to load the path.
In your home folder you should see a hidden .zsh.after folder
create a new file called 00-path.zsh
open that file and add the following :
path=(
$path
/usr/local/bin:
/usr/local/sbin:
/usr/bin:/bin:
/usr/sbin:
/sbin:
/Users/<YOUR_USERNAME>/.yadr/bin:
/Users/YOUR_USERNAME/.yadr/bin/yadr:
/Users/YOUR_USERNAME/Library/Android/sdk/tools:
/Users/YOUR_USERNAME/Library/Android/sdk/platform-tools/:
/Users/YOUR_USERNAME/Library/Android/sdk/build-tools/23.0.3/
)

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.

Why do I get the message of missing .bash and .sh files in the terminal starts?

First, I apologize if this is not the appropriate question, however, in the second thought it may qualify. Everytime I get the following message of missing files at the starts of the Mac terminal,
-bash: /Users/Chaklader/git-completion.bash: No such file or directory
-bash: /Users/Chaklader/git-prompt.sh: No such file or directory
Though, everything works fine, I just curious why do I get the message and what should I do to eliminate it ?
If you add these lines to your ~/.bash_profile it should clear them up.
. /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash
. /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh
Discussion Here with other solutions as well :) Hope this helps!

Resources