When I search for files in my home folder that have a filename equal to ".bash_history"
, I don't get any results, even though that file is there. How can I search for dotfiles in Finder? (I know how to find them in the terminal, however, some programs such as Integrated Development Environments have an open dialog that forces you to go through the Finder to locate the file you want to open).
2 Answers
In pretty much any Open or Save dialog in OSX Yosemite (and several previous versions) you can type shift + ⌘ commmd + . to make invisible files visible within the dialog.
So you can easily open TextEdit (or any given app).
Type ⌘ command + O.
Type shift + ⌘ command + . to reveal invisibles.
Type shift + ⌘ command + G in the Open Dialog and enter ~ (tilde) in the Go-To field to navigate to your home directory.
Type . + P to get to .profile or very close thereto.
Or as AMR says if you know it you can paste the whole path to the desired file in the Go-To field and get directly to it.
If necessary you can always display invisible files in the Finder itself. I've got this function in ~/.profile
to toggle them on/off.
#--------------------------------------------------------------------
# Task: Finder — Toggle All-Files-Visible On/Off
# dMod: 2015/07/29 02:48
# Test: Yosemite
#--------------------------------------------------------------------
function toglffvis()
{
if [ $(defaults read com.apple.finder AppleShowAllFiles) = 1 ]; then
defaults write com.apple.finder AppleShowAllFiles -boolean false
else
defaults write com.apple.finder AppleShowAllFiles -boolean true
fi
sleep 0.2;
killall Finder;
}
#--------------------------------------------------------------------
-
In Mavericks 10.9.5, shift + ⌘ command + . doesn't do anything in open windows (for me, at least). I do have AppleShowAllFiles enabled, but it still does not show up in the open file window.– MyerCommented Feb 2, 2016 at 14:29
.<filename>
is designated as a hidden file for OS X and Finder's search and Spotlight will not find them, even if you have made your hidden files visible.
You can however use the Terminal
to find the location of the file. Use:
find ~ -name ".bashrc"
Highlight and copy the path that is returned.
Then in the IDE dialog press shift + ⌘ command + G to display the Go input box.
Paste your path and filename there and you should be good to go.
Note: If you don't want to see all of the warnings of directories that your user account does not have access to, especially if you are running find on your root find /
, then you can run it with sudo
and that will avoid all of the Permission Denied warnings about searching locked directories.
ls
, at least in the Mac version of it still has.<filenames>
as hidden. You need to add-a
to be able to see them in the terminal.