Can Not Find .Profile File in OS X? Woo. You have to read and work a lot, otherwise you might end up setting a wrong profile file messing up the GUI too! Why this situation happens and do you really need to get in hand is important to understand. Unless you really need it (like your GUI is working fine, suddenly you developed and etching for getting the .Profile file). This typical situation, I Can Not Find .Profile File in OS X happens to the new OS X or rather pure UNIX users – either migrated from Linux or never used any *.nix system. Our polite advice will be – unless really you need the .Profile file and have done lot of customizations like Customizing iTerm2 with Color Schemes, Syntax Highlighting etc.
Be very honest! Either still now or once in remote past, you had less knowledge about UNIX. The question, Can Not Find .Profile File in OS X, is for the protective mechanism by UNIX for the new, enthusiastic users !
Can Not Find .Profile File OS X : Understanding the Issue
OS X runs path_helper which is where your default path get set. Read the article Mac OS X Change $PATH Variable Guide to understand this “path”. After that, it runs /etc/bashrc which does not do much work. Once the default configuration is set, it moves on to the user login scripts. Bash looks in your home directory for .bash_profile, .bash_login, and .profile in that order. bash will run the first of these that it finds and stop looking.
---
Also, some variables come from launchd (e.g. TMPDIR, SHELL, HOME, USER, LOGNAME, SSH_AUTH_SOCK, DISPLAY, Apple_PubSub_Socket_Render), Terminal (e.g. TERM, TERM_PROGRAM, TERM_PROGRAM_VERSION, COMMAND_MODE) and bash itself (PWD, SHLVL). Usually those files should reside in your /etc directory. In case when you don’t have your local copy of say .profile then the system uses /etc/profile. /etc/profile and ~/.profile is read for an interactive login shell, and ~/.bashrc is read for an interactive non-login shell.
By default, usually there is no .Profile file or any such thing, even if you are using iTerm2. We create this .Profile file ourselves manually. Try to understand the amount of possible profiles :
1 | https://github.com/mathiasbynens/dotfiles |
That is why we said to be honest! If you have not created it before customizations, its too lengthy and has enough chance to get wrong if you create one now. You must take a full backup of your everything on the Mac. With wrong configuration, it is unlikely that you can ever login to GUI properly. For more details, you can read this :
1 | http://hayne.net/MacDev/Notes/unixFAQ.html#shellStartup |
Can Not Find .Profile File OS X : Creating the .Profile File
We, normally never need it if once things are set. There is probably no such “automated” way to collect profile settings all from currently associated accounts in working condition and “automatically” create a .Profile file. We are using UNIX in this way for past 40 years! Because, this is a closed source OS, it is not possible or rather its a dangerous hacking to “scrap” (lack of better language) all profiles and dump on .Profile file. We are writing as .Profile for easy readability, it is all small letters – .profile.
In case, you have bought the Mac for the first time, you can run these commands :
1 2 3 | touch ~/.profile open -e ~/.profile #TextEdit will open up, simply save it. |
TextEdit will open up, simply save it. Close your Terminal or iTerm2 whatever you are using. You have to set those Syntax Highlighting things again.
Some readers got a kind of angry when we published this article. The reason is, the below steps :
Open iTerm2, and type :
1 2 | cd /usr/share/vim sudo vim vimrc |
And copy paste that all text like things from one vim-syntax.txt file. Use i to go in to insert mode to paste them. After pasting press Esc key. Then type :x and hit enter from keyboard.
The above steps are not right way, its a very bad shortcut. In case you have iTerm installed, you will have a .zshrc file at $HOME (=user directory). You can see the hidden files by going to $HOME and running commands in this way :
1 2 3 | cd $HOME ls -al open .zshrc |
Playing with this file for command line purpose (like decorating…) is better for the newbies.