mac软件问题和优化-旧版sublime的插件包下载失败

github 最近禁用了 tls1.0 加密协议,而此时mac系统上,旧版sublime,下载时会出现报错。查看sublime控制台报错信息:

Package info was unavailable last time crawler ran. Error downloading repository. HTTP exception InvalidCertificateException (Host api.github.com returned an invalid certificate ([SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:548))) downloading https://api.github.com/repos/rust-lang/sublime-rust.

然后查到:github 的问题贴

简单来说就是,mac版 sublime 用的下载模块是 urllib ,而urllib 是python自带的标准库,里面有ssl模块。而旧版python的ssl模块,采用ssl1.0连接服务器,所以导致高版本的ssl服务器拒绝连接。

解决办法是:打开sublime的
preferences->Package settings->Package control->Settings – User
添加如下代码:【也就是知道下载模块的第一优先级是使用 crul 模块】

"downloader_precedence":
	{
		"osx":
		[
			"curl",
			"urllib",
			"wget"
		]
	},

urllib是Python自带的标准库,无需安装,直接可以用。
提供了如下功能:

  • 网页请求
  • 响应获取
  • 代理和cookie设置
  • 异常处理
  • URL解析

爬虫所需要的功能,基本上在urllib中都能找到,学习这个标准库,可以更加深入的理解后面更加便利的requests库。

python 2.7  代码使用如下:

# request:GET
import urllib
response = urllib.urlopen('http://www.baidu.com')
print(response.read().decode('utf-8'))

英文问题讨论解析:


The problem is that the crawler is running on an old OS and Python 3.3, which doesn’t support TLS 1.2. wbond is already on it.

=====================================================

Python 3.3’s _ssl module uses the OpenSSL API in such a way that a connection to a TLS 1.2 server is not possible. It doesn’t use the TLS 1.1 or TLS 1.2 constants, but rather a constant for TLS 1.0. This results in GitHub rejecting the connection since it uses an insecure version of the TLS protocol.

Windows users by default use the WinInetDownloader, which uses the wininet library, and Microsoft’s TLS stack, so as long as they are running a recent build of Windows, they will have TLS 1.2.

Mac and Linux users default to using urllib, which utilizes the Python _ssl module.

mac系统问题和优化-openssl的更新问题

因为mac 现在主要用 LibreSSL,openssl的更新没有及时。

如果需要更新,可以用brew来安装 openssl,并将其设置为 系统默认的openssl。

cooldeMacBook-Pro:~ cool$ brew install openssl
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2p.el_capitan.bottle.tar.
######################################################################## 100.0%
==> Pouring openssl-1.0.2p.el_capitan.bottle.tar.gz
==> Caveats
A CA file has been bootstrapped using certificates from the SystemRoots
keychain. To add additional certificates (e.g. the certificates added in
the System keychain), place .pem files in
  /usr/local/etc/openssl/certs

and run
  /usr/local/opt/openssl/bin/c_rehash

openssl is keg-only, which means it was not symlinked into /usr/local,
because Apple has deprecated use of OpenSSL in favor of its own TLS and crypto libraries.

If you need to have openssl first in your PATH run:
  echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile

For compilers to find openssl you may need to set:
  export LDFLAGS="-L/usr/local/opt/openssl/lib"
  export CPPFLAGS="-I/usr/local/opt/openssl/include"

==> Summary
?  /usr/local/Cellar/openssl/1.0.2p: 1,793 files, 12.2MB
cooldeMacBook-Pro:~ cool$ openssl version
OpenSSL 0.9.8zh 14 Jan 2016
cooldeMacBook-Pro:~ cool$ 

调用方法一:更新系统环境变量:

cooldeMacBook-Pro:~ cool$ echo 'export PATH="/usr/local/opt/openssl/bin:$PATH"' >> ~/.bash_profile
cooldeMacBook-Pro:~ cool$ source  ~/.bash_profile
cooldeMacBook-Pro:~ cool$ openssl version
OpenSSL 1.0.2p  14 Aug 2018

调用方法二:

1、删除了.bash_profile中 的用户配置路径 openssl,
2、找到系统 /usr/bin/openssl 重命名乱连接,做备份 /usr/bin/openssl.bak
3、查看 新版openssl的安装目录:

cooldeMacBook-Pro:~ cool$ ls -l /usr/local/opt/openssl
lrwxr-xr-x  1 cool  admin  24 Oct 29 21:06 /usr/local/opt/openssl -> ../Cellar/openssl/1.0.2p

4、备份原来的/usr/bin/openssl,并重新设置系统openssl的软连接:

cooldeMacBook-Pro:~ cool$ sudo ln -s  /usr/local/Cellar/openssl/1.0.2p/bin/openssl  /usr/bin/openssl 
Password:
cooldeMacBook-Pro:~ cool$

关于python中的 ssl版本问题:

urllib是Python自带的标准库,无需安装,直接可以用。而urllib 是python自带的标准库,里面有ssl模块。也就是说python自带的的ssl模块与系统的openssl软件是无关的,版本号当然可以不相同。

cooldeMacBook-Pro:~ cool$ python -c "import ssl; print(ssl.OPENSSL_VERSION)"
OpenSSL 0.9.8zh 14 Jan 2016
cooldeMacBook-Pro:~ cool$ python
Python 2.7.10 (default, Oct 23 2015, 19:19:21) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.59.5)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ssl
>>> ssl.OPENSSL_VERSION
'OpenSSL 0.9.8zh 14 Jan 2016'
>>>

所以使用 旧版本的 urllib 库的 爬虫只支持ssl 1.0协议,导致ssl高版本协议的服务器拒绝与其连接。

HTTP exception InvalidCertificateException (Host codeload.github.com returned an invalid certificate ([SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:548))) downloading https://codeload.github.com/seanliang/ConvertToUTF8/zip/1.2.11.

mac软件问题和优化-自定义terminal主题

一、添加terminal新主题

在这篇博客中,我将把Solarized-Dark主题添加到我们的终端。下载好*.terminal然后直接用终端terminal打开就算主题安装好了。在终端的菜单属性栏可以指定主题。

Note: You can download various Themes (.terminal files) from this git repo. Simply open the *.terminal file to install it, i.e. right-click on the *.terminal file > “open with" > Terminal

  1. Go to http://ethanschoonover.com/solarized
  2. Scroll down and download the Theme (solarized.zip)
  3. Extract the solarized.zip file
  4. Open the osx-terminal.app-colors-solarized folder. This folder contains Theme for the terminal.
  5. Double click “Solarized Dark ansi.terminal” file — This is the specific Theme file for Terminal.app. Note: If you get a warning that this is from an unidentified developer, Right-click on the file and select “Open with” > Terminal option.
  6. At this point, you have the Theme installed into your Terminal. We just need to make it a default Theme.
  7. Open Terminal > Preferences > Text and select the “Solarized Dark …” theme and click on “Default”.

二、安装  Powerline

Powerline是一个Python应用程序,是vim的状态行插件,为几个其他应用程序提供状态行和提示,包括zsh,bash,tmux,IPython,Awesome和Qtile。

1、安装Python【mac系统默认已经安装好了】

通过python -V在终端中输入确保Python的版本是2.7.x.

  • 如果它不是2.7,请安装Homebrew,允许我们通过运行以下命令从CLI安装各种软件:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • 运行brew install python以通过Homebrew安装最新的Python

2、安装pip – Python的包管理器(类似于npm)

通过运行$ sudo easy_install pip  来安装pip。
出现ssl下载错误的话,可以用下面的方法安装pip:
根据网站https://pip.readthedocs.io/en/stable/installing/  提示:
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py

3、安装 command line developer tools

从App Store上下载Xcode后,默认是不会安装Command Line Tools的。Command Line Tools是Xcode中的一款工具,可以在命令行中运行C程序,同时又为其他软件提供操作系统服务的功能。

Command Line Tools【又叫 XCode Developer CLI tools】are used by Powerline and other apps that manipulate core OSX features. So make sure to install the XCode CLI tools by running the following command.

现在也来学习一下如何安装Command Line Tools:

方法一:Terminal 运行 xcode-select --install 然后点击安装
方法二:登录https://developer.apple.com/download/more/ 然后下载 dmg 安装
坑爹提醒: 网上复制粘贴这个 xcode-select —-install 到终端出现报错,仔细一看命令行居然是  – 和— 两个不同的破折号。

检验是否安装完成:

cooldeMacBook-Pro:~ cool$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates

或者:在xcode 中创建 OSX 的Application 项目时有 command line tool 选项。

4、安装Powerline

$ pip install --user powerline-status

添加powerline 后台进程 到bash,用于监控终端并及时作出响应。
(1)pip show powerline-status知道powerline安装目录。
(2)修改环境变量:

export PATH=$PATH:$HOME/Library/Python/2.7/bin
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /Users/rupa/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh

(3)生效环境变量
source ~/.bash_profile

三、 Powerline 与 本地化问题

打开终端后发现:

 File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/locale.py", line 475, in _parse_localename
    raise ValueError, 'unknown locale: %s' % localename
ValueError: unknown locale: UTF-8

查看问题 ‘unknown locale: %s’ % localename
解决办法是:在 .bash_profile 调用powerline之前就先添加上 本地化变量:
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

我的 .bash_profile 最终配置如下:

### 下面设置的本地化变量  是为了解决powerline 本地化报错问题,变量一定要在powerline运行前调用 
export LC_ALL=en_US.UTF-8
export LANG=en_US.UTF-8

export PATH=$PATH:$HOME/Library/Python/2.7/bin
powerline-daemon -q
POWERLINE_BASH_CONTINUATION=1
POWERLINE_BASH_SELECT=1
. /Users/cool/Library/Python/2.7/lib/python/site-packages/powerline/bindings/bash/powerline.sh

 

四、 安装 Powerline 字体

To install Powerline fonts, simply go to https://github.com/powerline/fonts. There you’ll see a whole bunch of folders. Each one is a font, aka “Patched fonts”.

It is called “Patched fonts” because people have taken regular fonts and have added/patched additional Powerline specific icons and fonts to them.

1、下载整个repo 仓库并解压。

(1)Click on the “Clone or download” button and download the whole repo so you try various fonts.
(2)Unzip the fonts-master.zip

字体安装双击 .ttf 文件就行,然后在终端的属性中进行选择。

Let’s open Meslo dotted fonts folder. It will look like below. You’ll see a whole bunch of .ttf file. Each one of them is a font but some are “bold” version of the font, some are “regular” version and so on.

Simply double-click on the .ttf file and press “Install font” to install the font on your computer.

For our case, let’s install “Meslo LG L DZ Regular for Powerline.ttf” and “Meslo LG L DZ Italic for Powerline.ttf”. This will add a regular and an Italic version of the Meslo font.

五、 安装 powerline的gitstatus插件

1、安装 powerline-gitstatus

pip install --user powerline-gitstatus

Note: “– user” command is required to install it in the user’s profile.

2、配置gitstatus 颜色显示

Add powerline-gitstatus color schemes to Powerline
(1)打开 colorschemes/shell/default.json 文件

${powerline-install-directory}/powerline/config_files/colorschemes/shell/default.json
//For example:
/Users/rupa/Library/Python/2.7/lib/python/site-packages/powerline/config_files/colorschemes/shell/default.json

(2) 添加各gitstatus 状态的颜色配置

{
  "groups": {
    "gitstatus":                 { "fg": "gray8",           "bg": "gray2", "attrs": [] },
    "gitstatus_branch":          { "fg": "gray8",           "bg": "gray2", "attrs": [] },
    "gitstatus_branch_clean":    { "fg": "green",           "bg": "gray2", "attrs": [] },
    "gitstatus_branch_dirty":    { "fg": "gray8",           "bg": "gray2", "attrs": [] },
    "gitstatus_branch_detached": { "fg": "mediumpurple",    "bg": "gray2", "attrs": [] },
    "gitstatus_tag":             { "fg": "darkcyan",        "bg": "gray2", "attrs": [] },
    "gitstatus_behind":          { "fg": "gray10",          "bg": "gray2", "attrs": [] },
    "gitstatus_ahead":           { "fg": "gray10",          "bg": "gray2", "attrs": [] },
    "gitstatus_staged":          { "fg": "green",           "bg": "gray2", "attrs": [] },
    "gitstatus_unmerged":        { "fg": "brightred",       "bg": "gray2", "attrs": [] },
    "gitstatus_changed":         { "fg": "mediumorange",    "bg": "gray2", "attrs": [] },
    "gitstatus_untracked":       { "fg": "brightestorange", "bg": "gray2", "attrs": [] },
    "gitstatus_stashed":         { "fg": "darkblue",        "bg": "gray2", "attrs": [] },
    "gitstatus:divider":         { "fg": "gray8",           "bg": "gray2", "attrs": [] }
  }
}

(3)激活gitstatus插件
Open Theme’s default.json file

${powerline-install-directory}/powerline/config_files/themes/shell/default.json
//For example:
/Users/rupa/Library/Python/2.7/lib/python/site-packages/powerline/config_files/themes/shell/default.json

Add the following to the default.json

{
    "function": "powerline_gitstatus.gitstatus",
    "priority": 40
}

(4)重启powerline后台进程
Save the file and run the following: powerline-daemon --replace in the Terminal.

Important Note: Every time you make changes to Powerline’s config, in addition to restarting the Terminal, you’ll also need to restart the daemon to see the changes reflected by running: powerline-daemon —-replace.

(5)重启终端,一切搞定

mac特有软件-Homebrew软件包管理器

一、安装homebrew

  • MacOS comes with Python installed already. Ensure Python’s version is 2.7.x by typing python -V in the Terminal.
  • If it’s not 2.7, install Homebrew that allows us to install various software from the CLI, by running:/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
  • Run brew install python to install the latest Python via Homebrew

安装pip

brew install pip
后来出现报错:提示

Error: No available formula with the name "pip" 
Homebrew provides pip via: `brew install python`. However you will then
have two Pythons installed on your Mac, so alternatively you can install
pip via the instructions at:
  https://pip.readthedocs.io/en/stable/installing/
cooldeMacBook-Pro:~ cool$

打开网页:显示操作
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py
sudo python get-pip.py

二、Homebrew设置代理

homebrew 使用 curl 下载的,所以只要 设置 curl的代理就可以了:

### 新建 .curlrc 文件
cooldeMacBook-Pro:~ cool$ vim  ~/.curlrc
### 编辑 代理内容 并保存退出
socks5 = 127.0.0.1:1086
##  代理内容的地址 其实也可以加上双引号
socks5 = "127.0.0.1:1080"


### 查看代理结果:

liuzhizhi@lzz-rmbp|logs # curl ip.cn
当前 IP:114.110.1.38 来自:北京市 广东恒敦通信技术北京分公司

liuzhizhi@lzz-rmbp|~ # curl cip.cc
IP  : 114.110.1.38
地址  : 中国  北京市
数据二 : 北京市 | 广东恒敦通信技术北京分公司
URL : http://www.cip.cc/114.110.1.38

liuzhizhi@lzz-rmbp|~ # curl myip.ipip.net
当前 IP:114.110.1.38  来自于:中国 北京 北京 联通/电信

三、Homebrew设置镜像源

  • 替换brew.git:
    cd "$(brew --repo)"
    git remote set-url origin https://mirrors.ustc.edu.cn/brew.git
  • 替换homebrew-core.git:
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://mirrors.ustc.edu.cn/homebrew-core.git
  • 替换Homebrew Bottles源:
    就是在/.bashrc或者/.zshrc文件末尾加

    export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.ustc.edu.cn/homebrew-bottles
    

    这两个文件可以自己创建,/.bashrc和/.bash_profile都可以

四、重置源

  • 重置brew.git
    cd "$(brew --repo)"
    git remote set-url origin https://github.com/Homebrew/brew.git
  • 重置homebrew-core:
    cd "$(brew --repo)/Library/Taps/homebrew/homebrew-core"
    git remote set-url origin https://github.com/Homebrew/homebrew-core.git
    

     

参考:https://www.jianshu.com/p/005963a4d843

mac踩坑-maven环境变量因文件夹隐藏后缀而写错

在mac 下 按照正常方式:配置maven 环境变量。

vim ~/.bash_profile

export JAVA_6_HOME=`/usr/libexec/java_home -v 1.6`
# 设置 JDK 7
export JAVA_7_HOME=`/usr/libexec/java_home -v 1.7`
# 设置 JDK 8
export JAVA_8_HOME=`/usr/libexec/java_home -v 1.8`

#默认JDK 7
export JAVA_HOME=$JAVA_7_HOME

#alias命令动态切换JDK版本
#alias jdk6="export JAVA_HOME=$JAVA_6_HOME"
alias jdk7="export JAVA_HOME=$JAVA_7_HOME"
#alias jdk8="export JAVA_HOME=$JAVA_8_HOME"

export M3_HOME=/Users/toy/Documents/maven/apache-maven-3.5.3
export PATH=$PATH:$M3_HOME/bin

export PATH=$PATH:"/Library/Tomcat/my_script_diy":"/Library/Tomcat/home/bin":"/usr/local/mysql/bin":"/Users/toy/Library/Android/sdk/platform-tools"
~                                                                               
~

注意配置路径的时候,路径名可以加分号,也可以不加。
export PATH 可以操作多次的。

编辑完maven后,保存。用命令行查看效果。

echo $PATH

/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/toy/Documents/maven/apache-maven-3.5.3/bin:/Library/Tomcat/my_script_diy:/Library/Tomcat/home/bin:/usr/local/mysql/bin:/Users/toy/Library/Android/sdk/platform-tools

然后 立即生效环境变量:
source ~/.bash_profile


正常情况下,应该没有问题了。

但是出现了 command not found 问题。我看 了一下,系统环境变量 路径都对的 啊。然后 进行排错。

1、文件权限,改完没有用

2、文件路径 改成了 Library 库目录里面,没有用。

3、利用Finder   go to folder  居然可以找到的。感觉路径的确没有问题啊 。

 

4.将 执行文件托人 terminal 中 发现 路径居然 有问题啊,问题的 关键找到了,

 

当时 原来是隐藏了 后缀名啊,巨坑。没想到 隐藏后缀名也能 用 Finder 搜索的到。坑爹。

mac常用操作-配置环境变量

经过测试 环境变量 配置时, 填写应用路径时 加双引号和 不加 双引号 都没有问题。
一、打开terminal,输入  echo $PATH  ,按回车执行命令查看当前变量值,这里我们将修改PATH变量来测试。

toydeMacBook-Pro:~ toy$ echo $PATH
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Users/toy/Library/maven/apache-maven-3.5.3/bin:/Library/Tomcat/my_script_diy:/Library/Tomcat/home/bin:/usr/local/mysql/bin:/Users/toy/Library/Android/sdk/platform-tools
toydeMacBook-Pro:~ toy$

二、先科普一下

mac 一般使用bash作为默认shell

Mac系统的环境变量,加载顺序为:
/etc/profile /etc/paths ~/.bash_profile ~/.bash_login ~/.profile ~/.bashrc
当然/etc/profile和/etc/paths是系统级别的,系统启动就会加载,后面几个是当前用户级的环境变量。后面3个按照从前往后的顺序读取,如果~/.bash_profile文件存在,则后面的几个文件就会被忽略不读了,如果~/.bash_profile文件不存在,才会以此类推读取后面的文件。~/.bashrc没有上述规则,它是bash shell打开的时候载入的。

如果没特殊说明,设置PATH的语法都为:
——————————————————-

# 中间用冒号隔开
 export PATH=$PATH:<PATH 1>:<PATH 2>:<PATH 3>:------:<PATH N>

三、(一)全局设置
下面的几个文件设置是全局的,修改时需要root权限

1)/etc/paths (全局建议修改这个文件 )
编辑 paths,将环境变量添加到 paths文件中 ,一行一个路径
Hint:输入环境变量时,不用一个一个地输入,只要拖动文件夹到 Terminal 里就可以了。

2)/etc/profile (建议不修改这个文件 )
全局(公有)配置,不管是哪个用户,登录时都会读取该文件。

3)/etc/bashrc (一般在这个文件中添加系统级环境变量)
全局(公有)配置,bash shell执行时,不管是何种方式,都会读取此文件。

4)
1.创建一个文件:
sudo touch /etc/paths.d/mysql
2.用 vim 打开这个文件(如果是以 open -t 的方式打开,则不允许编辑):
sudo vim /etc/paths.d/mysql
3.编辑该文件,键入路径并保存(关闭该 Terminal 窗口并重新打开一个,就能使用 mysql 命令了)
/usr/local/mysql/bin
据说,这样可以自己生成新的文件,不用把变量全都放到 paths 一个文件里,方便管理。

(二)单个用户设置

1)~/.bash_profile (任意一个文件中添加用户级环境变量)
(注:Linux 里面是 .bashrc 而 Mac 是 .bash_profile)
若bash shell是以login方式执行时,才会读取此文件。该文件仅仅执行一次!默认情况下,他设置一些环境变量
设置命令别名alias ll=’ls -la’
设置环境变量:

1

export PATH=/opt/local/bin:/opt/local/sbin:$PATH

2)~/.bashrc 同上

四、如果想立刻生效,则可执行下面的语句:
$ source 相应的文件
一般环境变量更改后,重启后生效。

如果你重启后生效了那就不用往下看了。
按照如上修改了~/.bash_profile文件发现无效,并且提示 zsh: command not found: homestead 那么肯定是安装了zsh的缘故,因为安装zsh,~/.bash_profile就不会被执行,解决办法如下:

1.打开vim ~/.zshrc 将你要配置到环境变量配置到该文件中即可

2.打开vim ~/.zshrc 添加source ~/.bash_profile ,这样~/.bash_profile配置的环境变量同样有效

zsh环境变量失效问题
新版的zsh在登录的时候默认只会加载~/.zshrc的配置文件,以前配置的环境变量会无效,尝试网上的各种方法均无效
发现配置文件有这样一条说明

If you come from bash you might have to change your $PATH.

于是简单粗暴的解决方案:
编辑~/.zshrc文件
在开头添加一下配置

export PATH=$HOME/bin:/usr/local/bin:$PATH
source $HOME/.bashrc
source $HOME/.bash_profile

参考:https://www.jianshu.com/p/8ef18883c958

五、以maven 作为环境变量 来举例 配置

  1. 打开terminel输入以下命令:

    vim ~/.bash_profile 打开.bash_profile文件,在次文件中添加设置环境变量的命令
    export M2_HOME=/Users/xxx/Documents/maven/apache-maven-3.5.0
    export PATH=$PATH:$M2_HOME/bin
    添加之后保存并推出,执行以下命令使配置生效:
    source ~/.bash_profile

  2. 查看配置是否生效

    1、输入:mvn -v命令,输入如下:

    Apache Maven 3.5.0 (ff8f5e7444045639af65f6095c62210b5713f426; 2017-04-04T03:39:06+08:00)
    Maven home: /Users/xxx/Documents/maven/apache-maven-3.5.0
    Java version: 1.8.0_121, vendor: Oracle Corporation
    Java home: /Library/Java/JavaVirtualMachines/jdk1.8.0_121.jdk/Contents/Home/jre
    Default locale: zh_CN, platform encoding: UTF-8
    OS name: "mac os x", version: "10.12.6", arch: "x86_64", family: "mac"

    则配置成功。

参考自:https://blog.csdn.net/hlllmr1314/article/details/52228672

mac系统问题和优化-显示隐藏文件的脚本

mac系统默认情况下无法查看隐藏文件,如果有需要可以使用脚本,显示隐藏文件。

脚本源代码如下:

display dialog "隐藏/显示隐藏文件" buttons {"可见", "隐藏"} with icon 2 with title "Switch to presentation mode" default button 1

set switch to button returned of result

if switch is "隐藏" then
	do shell script "defaults write com.apple.finder AppleShowAllFiles -bool false;
KillAll Finder"
	
else
	do shell script "defaults write com.apple.finder AppleShowAllFiles -bool true;
KillAll Finder"
	
end if

复制脚本源代码,然后 打开 Launchpad —>其他—>Script Editor
复制代码然后运行就可以了。或者选 文件 导出 成 application 也可以。