Mac 操作系统使用指南

开发环境

参考https://aaaaaashu.gitbooks.io/mac-dev-setup/content/iTerm/zsh.html
主要安装:

  • zsh
  • brew
  • iTerm2

环境变量

比如说你现在下载了一个二进制文件,希望将他加入到/usr/bin目录中打开终端直接输入命令就执行,你会发现,哪怕你这样执行

1
$ sudo cp -rf xxx /usr/bin/xxx

都没有效果,这是因为 mac 的安全机制阻止了你往重要的系统目录中写入文件,要解决也很简单,但是这种做法不推荐,我们可以这样操作

1.在当前用户的主目录下新建一个 bin 目录

1
$ mkdir ~/bin

2.将文件移动到该目录并且赋予可执行权限

1
2
$ mv upx-darwin-amd64-v0.2.1 ~/bin/upx 
$ chmod +x ~/bin/upx

3.编辑 shell 的配置文件,我这里使用的是 zsh,所以我需要编辑 zshrc

1
$ vim ~/.zshrc

4.增加

1
export PATH=$HOME/bin:$PATH

5.使环境变量生效

1
source ~/.zshrc

6.然后在打开终端输入 upx 试试

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
➜  ~ upx
NAME:
upx - a tool for driving UpYun Storage

USAGE:
upx [global options] command [command options] [arguments...]

VERSION:
v0.2.1 darwin/amd64 go1.6

AUTHOR(S):
Hongbo.Mo <[email protected]>

COMMANDS:
login Log in to UpYun
logout Log out of your UpYun account
sessions List all sessions
switch Switch to specific session
info Current session information
cd Change directory
pwd Print working directory
mkdir Make directory
ls List directory or file
tree List contents of directories in a tree-like format
get Get directory or file
put Put directory or file
rm Remove directory or file
sync Sync local directory to UpYun
auth Generate auth string
post Post async process task
help, h Shows a list of commands or help for one command

GLOBAL OPTIONS:
--quiet, -q not verbose
--auth value auth string
--help, -h show help
--version, -v print the version

➜ ~