在 osx 中显示系统文件/显示 git ignore

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11197249/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:00:58  来源:igfitidea点击:

Show system files / Show git ignore in osx

macosgit

提问by Jay

By default it is not possible to see .gitignore files in osx. What is command to reveal these files?

默认情况下,无法在 osx 中看到 .gitignore 文件。显示这些文件的命令是什么?

回答by Snarf

Open the terminal and type

打开终端并输入

  • on OS X 10.8:

    defaults write com.apple.Finder AppleShowAllFiles TRUE
    
  • on OS X 10.9:

    defaults write com.apple.finder AppleShowAllFiles TRUE
    
  • 在 OS X 10.8 上:

    defaults write com.apple.Finder AppleShowAllFiles TRUE
    
  • 在 OS X 10.9 上:

    defaults write com.apple.finder AppleShowAllFiles TRUE
    

Then you must relaunch finder:

然后你必须重新启动finder:

killall Finder

Any file name in OS X prefixed with a '.' is considered "hidden".

OS X 中以“.”为前缀的任何文件名 被认为是“隐藏的”。

回答by roosto

??.will toggle the AppleShowAllFilessetting.

??.将切换AppleShowAllFiles设置。

This key combo will work from open/save dialogue boxes in all apps, not just the finder. Use this and you'll never be confused when on someone else's Mac or a new Mac, and you can avoid mucking around with defaults write.

此组合键可在所有应用程序中的打开/保存对话框中使用,而不仅仅是查找程序。使用它,您在使用其他人的 Mac 或新 Mac 时永远不会感到困惑,并且您可以避免使用defaults write.

I use the nemonic of “use a dot to show a dot file” to remember it, because of hidden dot files in unix.

我使用“使用一个点来显示一个点文件”的助记符来记住它,因为在 unix 中隐藏了点文件。

回答by prodigitalson

if you just want to look at them you can always use the command line:

如果您只想查看它们,您可以随时使用命令行:

ls -al path/to/dir

ls -al path/to/dir

If you want to always view allfiles from the finder you can do:

如果您想始终从查找器中查看所有文件,您可以执行以下操作:

defaults write com.apple.Finder AppleShowAllFiles YES

defaults write com.apple.Finder AppleShowAllFiles YES

If you just want to view a .gitignore from the finder you can:

如果您只想从查找器中查看 .gitignore,您可以:

chflags nohidden /path/to/dir/.gitignore

chflags nohidden /path/to/dir/.gitignore

But youll have to call that command on every .gitignoreits not global.

但是你必须在每个.gitignore非全局命令上调用该命令。

回答by Sze-Hung Daniel Tsui

(more recent, for 10.10.2:)

(最近,对于 10.10.2 :)

The above commands didn't work for me. I'm using OSX Yosemite: 10.10.2. This worked though:

上面的命令对我不起作用。我正在使用 OSX Yosemite:10.10.2。这虽然有效:

defaults write com.apple.finder AppleShowAllFiles -boolean true;
killall Finder;

Source: http://www.idownloadblog.com/2014/08/04/how-to-show-hidden-files-folders-finder-mac/

来源:http: //www.idownloadblog.com/2014/08/04/how-to-show-hidden-files-folders-finder-mac/

回答by DevAnuragGarg

You can use the shortcut in Finder:

您可以使用 Finder 中的快捷方式:

Command+ Shift+ .

Command+ Shift+.

It will show the hidden files. To hide the files again, use the same shortcut.

它将显示隐藏文件。要再次隐藏文件,请使用相同的快捷方式。

回答by Cong Dan Luong

You can edit hidden file in terminal using this command

您可以使用此命令在终端中编辑隐藏文件

open -a TextEdit .gitignore 

回答by HendrikKoelbel

To view the hidden file on an iMac or MacBook in the Finder, simply press this key combination.

要在 Finder 中查看 iMac 或 MacBook 上的隐藏文件,只需按下此组合键即可。

Command (?)+ Shift (?)+ .

Command (?)+ Shift (?)+.

If you want to hide these files, press the same combination again.

如果要隐藏这些文件,请再次按相同的组合。

回答by akcasoy

If you just want to view a .gitignore from the console just type "nano .gitignore" in that directory. This command "nano" simply opens any textfile in nano console environment for viewing or editing

如果您只想从控制台查看 .gitignore,只需在该目录中键入“nano .gitignore”。此命令“nano”只是在 nano 控制台环境中打开任何文本文件以进行查看或编辑

回答by akcasoy

In addition to the accepted answer, you can create an alias to easily show/hide the hidden files in Terminal. This is how I set it up (tested/working on macOS Mojave 10.14.1).

除了接受的答案之外,您还可以创建别名以轻松显示/隐藏终端中的隐藏文件。这就是我的设置方式(在 macOS Mojave 10.14.1 上测试/工作)。

In my user directory I created a new file .custom_aliasesand wrote this in:

在我的用户目录中,我创建了一个新文件.custom_aliases并将其写入:

# Show/hide files
alias showall='defaults write com.apple.finder AppleShowAllFiles -boolean true; killall Finder'
alias hideall='defaults write com.apple.finder AppleShowAllFiles -boolean false; killall Finder'

Next I opened .bash-profile(should also be in your user directory, if not just create it there) and added this to the top of the file:

接下来我打开.bash-profile(也应该在你的用户目录中,如果不只是在那里创建它)并将它的添加到文件的顶部:

# Load custom aliases
source ~/.custom_aliases

And that's it! Now whenever I need to view the hidden files I just type showallin Terminal and hideallwhen I'm done. You could also define the aliases directly in the .bash_profile, but I have some other stuff so I like to keep all the aliases together in a separate file.

就是这样!现在,每当我需要查看隐藏文件时,我只需showall在终端中hideall输入即可。您也可以直接在 中定义别名.bash_profile,但我还有其他一些东西,所以我喜欢将所有别名放在一个单独的文件中。

回答by Shomu

Show hide file and folder on MacOs Mojave 10.14.4

在 MacOs Mojave 10.14.4 上显示隐藏文件和文件夹

Apply at Terminal

在航站楼申请

defaults write com.apple.finder AppleShowAllFiles -boolean true;
killall Finder;