Installing flutter bash_profile - terminal

I'm trying to install flutter
I need to create with the terminal a file named bash_profile
I tried to create it but each time that I'm trying, I'm getting a bash_profile file with an extension: bash_profile.swo and bash_profile.swp instead of bash_profile.
How can I remove the 2 bash_profile.swo and bash_profile.swp?
thank you

You can simply use echo '' >> .bash_profile.
You can also use the touch command to do it.
Remember that bash_profile file is a occulted file. you probably already have this file, try check it by running ls -la.
and you must to use a 'dot' before 'bash' >> .bash

Related

zsh: command not found on MacOS Monterey

I wanted to create a react project and when I executed the command it said zsh: command not found: npx
Then I tried the ls command and it said zsh: command not found: ls.
After setting the export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command both the ls and npx create-react-app command worked fine and when close the terminal and reopen again, the same command not found error shows.
Is there any permenent fix without setting export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin" command
For adding the variables to the path you need to add it to zshrc file for making that variable available locally.
The way you have used will only work until you use it in the same terminal window path only.
To solve the problem, follow these steps:
Goto you home directory
Simultaneously press cmd + shift + (.) Note:the last key is the key of dot
On following step 2, new hidden files will appear in home directory, look for (.zshrc) file and open it using any text editor.
Add your path variable in it, save and then close it.
Example: export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin"
Open terminal and run the command: "echo $PATH" and see if your added variable is present in the output shown by terminal.
If yes, You are now ready to go to use it from anywhere in terminal now.
This is what worked for me on macOS Monterey,
Although I added the path to ./zshrc and sourced the file, after reopening the terminal the PATH was not exported
I followed these steps to solve this
Created .zprofile with touch .zprofile at the home directory. If the file already exists use that.
Add the required path to this file using vim or nano
eg: export PATH=${PATH}:/Users/Development/HashBaze/flutter/bin
If the above two steps don't work try sourcing both the .zprofile and .zshrc after following the above two steps.
This solution worked for me on macOS Monterey version 12.5

How to set .bash_profile, if it does not exist yet. I want to launch sublime from a command line in Mac

I want to launch sublime from a command line in Mac, using subl filename. It seems to involve dealing with .bash_profile. But I didn't locate the file. What steps to be taken?
A typical install of OS X won't create a .bash_profile for you. When you want to run functions from your command line, this is a must-have.
Start up Terminal
Type cd ~/ to go to your home folder
Type touch .bash_profile to create your new file.
Edit .bash_profile with your favorite editor (or you can just type open -e .bash_profile to open it in TextEdit.
Type . .bash_profile to reload .bash_profile and update any functions you add. Notice the space between the two dots!
Update
I'm on Mac OS Mojave.
Open Terminal.app and paste bellow line,
(1) touch .bash_profile
(2) open -a TextEdit.app .bash_profile
this will open a blank page in TextEdit.app , from here you can add,update,delete code.
I hope this will help someone.
just create a new file - it doesn't come default with your computer. all under your user directory - ex. /Users/username
touch .bash_profile
~/.bash_profile
Q1. How to check if .bash_profile exists or not in my mac?
Solution: If you're using macOS 10.14 (Mojave) or below. Then open the Terminal.app. Run the following command to check if the .bash_profile exists or not in your mac.
if [ -r ~/.bash_profile ];
then
echo "Yes, file exists"
else
echo "No, file does not exists"
fi
After running the above command if you get the following line - "Yes, file exists" printed in your Terminal.app. That means the file exists in your mac.
If you get the following line - "No, file does not exist" printed in your Terminal.app. That means the file does not exist in your mac.
To create a .bash_profile file in your mac. Run the following command,
touch ~/.bash_profile
To restrict access to the .bash_profile. Run the following command,
chmod 700 ~/.bash_profile
Q2. I want to launch sublime from a command line in Mac?
Solution: To launch sublime from mac. You can make a symlink to subl. Assuming you've placed Sublime Text in the Applications folder, and that you have a ~/bin directory in your path, you can run the following command:
ln -s "/Applications/Sublime Text.app/Contents/SharedSupport/bin/subl" ~/bin/subl
For more details visit the official sublime documentation

Terminal is not working as usual mac after trying to install CakePHP

I was downloading the CakePHP framework for a project. Below the steps:
Installation
1) Install PHP 5.6 from: http://php-osx.liip.ch/
curl -s http://php-osx.liip.ch/install.sh | bash -s 5.6
2) add the updated PHP version to our path. So we edit .profile file
nano ~/.profile
Add into the file
export PATH= /usr/local/php5/bin:$PATH
Then hit Control + O to write out the file
Then hit Control + X to save the file
exit
Restart the Terminal
Now the terminal doesn't work as usually. I've tried to understand the shell concept and apply different solutions, but I can't even find the .profile file again.
I obtain errors like:
enter code here-bash: ls: command not found
Anybody can explain me what's wrong and the shell concept to properly understand shell (-bash)?
The problem is this:
export PATH= /usr/local/php5/bin:$PATH
You killed your PATH variable. You need to find a way to edit .profile file, and change that line to:
export PATH=$PATH:/usr/local/php5/bin
You could try editing with the following command (using vim):
/usr/bin/vim /Users/yourname/.profile
Or (using nano):
/usr/bin/nano /Users/yourname/.profile
Or just remove .profile file completely by doing /bin/rm /Users/yourname/.profile. Of course, in any case, you need to restart your terminal once you're done.

How can I edit bash_profile if open command does not work and hidden file does not open in mac

I tried to change something in my bash_profile but I think I mistyped something. So I can not run any terminal commands. If I post "ls" command then I get
-bash: ls: command not found
Now I can not open bash_profile also. So what can I do here. I get the below path using echo command but there was some any other path. Please help.
echo $PATH: /usr/local/bin:/usr/local/bin:
But if I write /bin/ls it works.
MacBook Pro El Capitan : 10.11.4
This is the possible answer - And I solved it using nano editor
You messed up your PATH environment variable.
/bin/ls
works because you did not need PATH to find the 'ls' program. You can run ANY command by specifying its full path.
You need to re-edit your .bash_profile to either remove your PATH, or fix it. I do not know what editor you used to modify .bash_profile to begin with, but you can use
/usr/bin/nano
/usr/bin/vi (ONLY if you know vi/Vim)
/usr/bin/vim (ONLY if you know vi/Vim)
/usr/bin/emacs (I shutter to think about this)
TextWrangler (a very good free GUI text editor)
http://www.barebones.com/products/textwrangler/
Or you can just rename the current .bash_profile and start a new terminal session, then fix the renamed .bash_profile before putting it back in service
/bin/mv .bash_profile saved.bash_profile

How does one locate a .zshrc file?

I used Homebrew to install Z shell (zsh) 5.0.7 on my Mac.
For the life of me, .zshrc is nowhere to be found. It is not in ~. Is is not in /etc or /etc/zshrc as they suggest here: http://zshwiki.org/home/config/files
Am I supposed to create it myself?
Sure. If it's not there already, create it yourself.
$ touch ~/.zshrc
You can run the helper script zsh-newuser-install from the prompt, and it will walk you through the process to create an initial .zshrc in your home directory.
As kyranjamie mentioned, you can create it using following command
$ touch ~/.zshrc
Example content of .zshrc file:
PATH=$PATH:/your_path_goes_here
In order to find any file on a Unix-based system, you can try the command:
$ locate filename
It should list all the paths where the corresponding file exists.
In Unix based systems, touch command followed by name will create an empty file in the present directory.
the modification and access time of each file is also updated with the use of touch command.
In your case, to create .zshrc file, you can use the touch command as :
$ touch ~/.zshrc

Resources