How to create .zshrc in Mac home directory? - macos

I have started using Mac for the first time and I am trying to set up flutter. One of the steps is to add path in file .zshrc. For this I have to first create this file. In Windows, whenever I had to create file, I used Git Bash and use touch <filename> in any directory and the file was created. Some websites mention that touch works in Mac terminal also.
How to create this file in home directory? I tried going to the home directory using cd ~ and then touch .zshrc and touch ~/.zshrc but they don't seem to work. I also tried to save file with this extension using TextEdit but doesn't work either. I have checked Show all filename extensions in Finder > Preferences > Advanced.
So what is the way to create this file in home directory either using Finder or terminal?

Related

How to find where my PATH variable is being generated and how to edit it in Mac OSX Terminal?

Currently I am in Mac OSX and when I try to find what my PATH is via Terminal, I get:
> echo $PATH
/Users/User1/google-cloud-sdk/bin:/usr/local
/bin:/usr/local/sbin:/usr/local/bin:
/usr/bin:/bin:/usr/sbin:/sbin:
/Library/TeX/texbin:/opt/X11/bin:
/Applications/Wireshark.app/Contents/MacOS
I would like to remove google-cloud-sdk, wireshark, and tex from PATH, but have no idea how to do it. When I look inside my etc/profile file, none of these apps are listed. Is there a way to clean up by $PATH? Thanks.
I just found the Wireshark path file in :
/etc/paths.d/
Go to your home directory. If you open a fresh Terminal window/session, this will probably have you in your home directory.
Type,
ls -al
This should give you a list of the files in your home directory, including invisible files. Check there is a file called .bash_profile. The "." means it is an invisible file.
If that exists (as it should) type:
nano .bash_profile
This will open this file in the text editor program called "nano". In this file you should find statements like:
export PATH="/Library/Frameworks ....
There should be similar PATH statement for the options you want to remove.
Delete those lines and then exit nano by ^O for writing out, and you need to print Y to save. Then ^X to exit nano.

Is it possible to create multiple references to a file on Macintosh?

What I mean is that I want the same file to exist in 2 different locations, so that when I save it in 1 location it updates in the other location. I'm running OSX Yosemite, btw. Is this possible?
If you're looking to have the file on the same computer, a symlink will do the trick:
Fire up terminal
Navigate to the directory you want to have the symlink in cd /path/to/your/file
do ln -s /any/file/on/the/disk linked-file where "linked-file" will be the name of the file you want
If you're looking to have the file on a separate computer or on a network drive, you should probably look into rsync.

How do I access my iCloud Drive folder from Terminal?

I'm running OS X Yosemite. I would like to save my code folder in iCloud Drive so that it's automatically backed up. I need to access files from the Terminal often, so how can I access iCloud Drive from the Terminal?
cd ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/
I would just add a symbolic link either to this folder or to a Source subfolder in your home directory to make working with this easier.
For example:
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs ~/iCloud
and/or
ln -s ~/Library/Mobile\ Documents/com\~apple\~CloudDocs/Source ~/Source
It´s in the Library Folder of the user. The folder-name is "MobileDocuments".
It's in ~/Library/Mobile\ Documents/com\~apple\~QuickTimePlayerX/Documents/....
How to find it? You can drag a file in the finder and drop the file to the terminal, then the file path would be displayed in the terminal.
This is an awful way to get the path, I'm very curious about how to reveal it more naturally and easily and gracefully.

Whats different when you executable a scripts in OSX?

I have a question I have been trying to fix for a while. I want to understand what's the difference between starting a script from the command line and making it executable and then running it from the Finder.
Because this is what I am experiencing;
I have a simple script called trash-files which contains this command:
trash ~/Downloads/*
When I run from the terminal it works as expected; however if I doubleclick the shell script in the finder I see this:
/Users/xx/Desktop/trash-files: line 1: trash: command not found
I hope anyone can tell me why this doesn't work as expected
trash is not a standard command in OS X. Is it something defined in your ~/.profile or a similar file? If so, these are not run for non-login shells, such as those created to run a script.
If you're using homebrew, you could run
brew install trash
which would install the necessary scripts to have the trash command work in the way you're expecting.
There is a folder in your home folder location called
.Trash
The "dot" in front of the folder name makes it hidden while searching for it in finder. You'll have to use Terminal to execute the following command:
cd ~/
ls -la
This will change the directory to the current logged in users home folder, then second command will list files and show hidden files. You can then run:
rm .Trash/*
This will remove everything inside the Trashcan on the dock.
So open TextEdit from the /Applications folder, go to "Format" and make it "Plain Text". Paste in the two lines below.
#!/bin/sh
rm ~/.Trash/*
Save the file as "emptyTrash.sh" (uncheck use txt extension). Save it to your Desktop or wherever you'd like. Then open Terminal, cd (change directory) to where the files is and run this command to make the script executable:
chmod +x emptyTrash.sh
Then you can execute the script by cd (changing directory) to path where the script is, and run:
./emptyTrash.sh
That's it.

where is ~\.vim folder in mac os? and how to install themes in gvim?

I downloaded color sample pack from http://vim.sourceforge.net/scripts/script.php?script_id=625
it says i should unzip and place it into ~/.vim but where is this folder? I tried unzip it to my usr/share/.vim folder but it is not working, I don't see themes added to gvim Edit>color scheme menu, and i tried "colorscheme sometheme", "color sometheme" in my gvimrc. Both not working for new themes
Isn't the ~/.vim should be the .vim folder in use/share? or I should create a new folder under home?
Note:there is a folder vim73 in my .vim, I guess this doesn't affect anything
thanks for any help!
First of all, open vim, and get help from :help colorscheme
:colo[rscheme] {name} Load color scheme {name}. This searches 'runtimepath'
for the file "colors/{name}.vim. The first one that
is found is loaded.
After reading the manual above.
Take the following steps maybe help you:
find runtimepath
:set runtimepath?
It will print out run-time paths:
runtimepath=~/.vim,/usr/share/vim/vimfiles,/usr/share/vim/vim71,/usr/share/vim/vimfiles/after,~/.vim/after
create directory called colors under one of them if not exist(for example: ~/.vim)
$ ls ~/.vim
ls: cannot access /root/.vim: No such file or directory <== we need create it!!!
$ mkdir -p ~/.vim/colors
copy your color.vim to your colors directory
$ cp /path/to/your/color.vim ~/.vim/colors
restart vim to use new colorscheme
:colorscheme color
(optional) put command above to ~/.vimrc file to make it permanent
In UNIX parlance, ~ represents your home folder which is /Users/<username> in Mac OS X.
You are supposed to put all your custom scripts/colorschemes/whatever in a .vim folder situated in your home folder. In Terminal.app, type each line (without the $) then hit Enter:
$ cd
to be sure you are in your home folder
$ mkdir .vim
here you'll have an error message if ~/.vim already exists; if you don't receive a message it means that the folder is created
$ cd .vim
to move into it
$ open .
to open a Finder window here. At this point you should follow specific indications.

Resources