MAC 开发配置

Mac使用的一些配置,软件等记录

配置

Java Home设置

With the Java optional package or Oracle JDK installed, adding one of the following lines to your ~/.bash_profile file will set the environment variable accordingly.

export JAVA_HOME="$(/usr/libexec/java_home -v 1.6)"
or
export JAVA_HOME="$(/usr/libexec/java_home -v 1.7)"
or
export JAVA_HOME="$(/usr/libexec/java_home -v 1.8)"

运行程序提示被修改需要删除

sudo spctl --master-disable

设置Hostname

sudo scutil --set HostName <name>

设置环境变量

~/Library/LaunchAgents/里面创建文件environment.plist内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>my.startup</string>
<key>ProgramArguments</key>
<array>
<string>sh</string>
<string>-c</string>
<string>
launchctl setenv SPARK_HOME /Users/haseochen/Documents/spark-2.1.0-bin-hadoop2.6
launchctl setenv PYSPARK_PYTHON /Users/haseochen/anaconda/bin/python
launchctl setenv PYTHONPATH Users/haseochen/Documents/spark-2.1.0-bin-hadoop2.6/bin:/Users/haseochen/Documents/spark-2.1.0-bin-hadoop2.6/python:/Users/haseochen/Documents/spark-2.1.0-bin-hadoop2.6/python/lib/py4j-0.10.4-src.zip
launchctl setenv PRODUCTS_PATH /Users/mortimer/Projects/my_products
launchctl setenv ANDROID_NDK_HOME /Applications/android-ndk
launchctl setenv PATH $PATH:/Applications/gradle/bin
</string>

</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>

你可以在<string></string>段之间增加多个launchctl命令
plist会在系统重启后生效。你可以可以执行aunchctl load ~/Library/LaunchAgents/environment.plist立即生效

访问共享

在自带的Finder中点击菜单Go->Connect to Server… 输入服务器地址即可

afp://osx-server01/software  //MAC共享
smb://win-client01/Work-Docs //Win共享
nfs://lin-server01/software //Linux
http://xxxxx/xxxxx
ftp://10.1.104/

修改PATH变量

vim /etc/paths

禁止chorm手势

defaults write com.google.Chrome AppleEnableSwipeNavigateWithScrolls -bool FALSE

终端命令

粘贴剪贴板内容至终端->排序->去重->重定向到剪贴板

1
pbpaste | sort | uniq | pbcopy

卸载文件夹

diskutil eject /dev/disk1

显示系统信息

system_profiler

查询文件内容

mdfind "Mark Twain"

屏幕截图

screecapture ~/Desktop/screencap.jpg

Shell 命令

批量替换文件内容

find . -type f -name '*.sh' -exec sed -i '' 's/stringA/stringB/g' {} +

Mac OS X显示链接 netstat lsof

其他

终端sudo使用Touch ID
编辑/private/etc/pam.d/sudo文件在其中添加一行auth sufficient pam_tid.so现在内容如下:

# sudo: auth account password session
auth sufficient pam_tid.so
auth       sufficient     pam_smartcard.so
auth       required       pam_opendirectory.so
account    required       pam_permit.so
password   required       pam_deny.so
session    required       pam_permit.so

iTerm2

iTerm 终端配置

Zsh

以下两个包安装好以后我感觉默认够用了

brew install zsh zsh-completions

man结果高亮

# man page highlight
export LESS_TERMCAP_mb=$'\E[01;31m'       # begin blinking
export LESS_TERMCAP_md=$'\E[01;38;5;74m'  # begin bold
export LESS_TERMCAP_me=$'\E[0m'           # end mode
export LESS_TERMCAP_se=$'\E[0m'           # end standout-mode
export LESS_TERMCAP_so=$'\E[38;5;246m'    # begin standout-mode - info box
export LESS_TERMCAP_ue=$'\E[0m'           # end underline
export LESS_TERMCAP_us=$'\E[04;38;5;146m' # begin underline

Visual Studio Code

Visual Studio Code 使用插件及设置

Rime输入法—鼠须管

神级输入法「鼠鬚管」配置指南

MySQL

brew install mysql

We’ve installed your MySQL database without a root password. To secure it run:
mysql_secure_installation

MySQL is configured to only allow connections from localhost by default

To connect run:
mysql -uroot

To have launchd start mysql now and restart at login:
brew services start mysql
Or, if you don’t want/need a background service you can just run:
mysql.server start

参考

macOS Setup Guide

打赏支持:如果你觉得我的文章对你有所帮助,可以打赏我哟。