Homebrew MacPorts Fink

目录 MacOS


sudo chown -R `whoami` /usr/local
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
echo 'export PATH="/usr/local/bin:$PATH"' >> ~/.bash_profile
brew update                   #更新Homebrew
brew upgrade                  #升级软件
brew search formula           #查找
brew install formula          #安装
brew uninstall formula        #卸载
brew list                     #列出已安装的软件
brew home formula             #用浏览器打开
brew info formula             #显示软件内容信息
brew deps formula             #显示软件的依赖
brew -h                       #帮助


sudo port -v selfupdate       #更新
port search formula           #搜索
port install formula          #安装
port uninstall formula        #卸载
port outdated                 #查看有无更新的软件以及版本
port upgrade outdated         #升级可以更新的软件
port list                     #列出所有的可用软件
port info formula             #查看软件的详细信息
port deps formula             #查看软件的依赖
port clean --all formula      #删除软件安装过程中所产生的一些临时文件
port dependents formula       #查看依赖


fink selfupdate               #升级
fink install formula          #安装
fink reinstall formula        #重新安装
fink remove formula           #卸载软件,如果想把依赖包也一起卸载,加-r
fink update-all               #更新所有的软件
fink list                     #查看可用软件
fink info formula             #查看相关软件的信息
fink show-deps formula        #显示软件的依赖关系


Vim set

目录 MacOS


/usr/share/vim/vimrc #只读,无法修改
vim ~/.vimrc         #自己创建.vimrc文件


syntax on
set laststatus=2
set tabstop=2
set softtabstop=2
set shiftwidth=2
set expandtab
set smarttab
set autoindent
set smartindent
set number
set ruler
set backupdir=/tmp
set directory=/tmp
set ignorecase
set hls
set helplang=cn
set foldmethod=syntax


source ~/.vimrc

environment variables

目录 MacOS


/etc/bashrc      #只读,全局(公有)配置
/etc/profile     #只读,全局(公有)配置
~/.bash_profile  #用户级环境变量


vim ~/.bash_profile
export CLICOLOR=1
export LSCOLORS=GxFxCxDxBxegedabagaced
#\h:\W \u\$
export PS1='\[\033[01;33m\]\u@\h\[\033[01;31m\] \W\$\[\033[00m\] '
export PATH=/usr/local/bin:$PATH


source ~/.bash_profile

ssh sftp ftp

目录 MacOS

由于学习需要,经常要登录到服务器上操作,在window系统下,有许多好用的工具,如SSH Secure Shell Client等,而MacOS系统也有许多客户端,如iterm2,File Zilla,ZOL,Shuttle等。下面介绍一下MacOS终端自带的SSH,是标准的OpenSSH client。基本用法如下:

ssh user@host   #输入密码登录服务器


Host alias-name
    HostName ip_address
    Port 22
    User user


ssh alias-name  #输入密码登录服务器


scp <local file> <remote user>@<remote machine>:<remote path>    #本地文件传到服务器上
scp <remote user>@<remote machine>:<remote file> <local path>    #服务器文件下载到本地
scp -r <local file> <remote user>@<remote machine>:<remote path> #本地文件夹传到服务器上
scp -r <remote user>@<remote machine>:<remote file> <local path> #服务器文件夹下载到本地


sftp user@host  #输入密码登录服务器
sftp> help      #帮助信息
Available commands:
bye                                Quit sftp
cd path                            Change remote directory to 'path'
chgrp grp path                     Change group of file 'path' to 'grp'
chmod mode path                    Change permissions of file 'path' to 'mode'
chown own path                     Change owner of file 'path' to 'own'
df [-hi] [path]                    Display statistics for current directory or
                                   filesystem containing 'path'
exit                               Quit sftp
get [-afPpRr] remote [local]       Download file
reget [-fPpRr] remote [local]      Resume download file
reput [-fPpRr] [local] remote      Resume upload file
help                               Display this help text
lcd path                           Change local directory to 'path'
lls [ls-options [path]]            Display local directory listing
lmkdir path                        Create local directory
ln [-s] oldpath newpath            Link remote file (-s for symlink)
lpwd                               Print local working directory
ls [-1afhlnrSt] [path]             Display remote directory listing
lumask umask                       Set local umask to 'umask'
mkdir path                         Create remote directory
progress                           Toggle display of progress meter
put [-afPpRr] local [remote]       Upload file
pwd                                Display remote working directory
quit                               Quit sftp
rename oldpath newpath             Rename remote file
rm path                            Delete remote file
rmdir path                         Remove remote directory
symlink oldpath newpath            Symlink remote file
version                            Show SFTP version
!command                           Execute 'command' in local shell
!                                  Escape to local shell
?                                  Synonym for help
sftp>put /path/filename(本地主机) /path/filename(远端主机) #上传文件
sftp>get /path/filename(远端主机) /path/filename(本地主机) #下载文件


ftp example.com
Connected to example.com.
220 Welcome to www.net.cn FTP service.
Name (example.com:$): user
331 Please specify the password.
230 Login successful.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> help
Commands may be abbreviated.  Commands are:
!       chmod       fget        less        mlst        open        pwd     rhelp       struct      verbose
$       close       form        lpage       mode        page        quit        rmdir       sunique     xferbuf
account     cr      ftp     lpwd        modtime     passive     quote       rstatus     system      ?
append      debug       gate        ls      more        pdir        rate        runique     tenex
ascii       delete      get     macdef      mput        pls     rcvbuf      send        throttle
bell        dir     glob        mdelete     mreget      pmlsd       recv        sendport    trace
binary      disconnect  hash        mdir        msend       preserve    reget       set     type
bye     edit        help        mget        newer       progress    remopts     site        umask
case        epsv4       idle        mkdir       nlist       prompt      rename      size        unset
cd      exit        image       mls     nmap        proxy       reset       sndbuf      usage
cdup        features    lcd     mlsd        ntrans      put     restart     status      user

install GD on MacOS

目录 MacOS

转自Qinhu Wang | 王秦虎
Various applications depend on library GD, however, you will alway fail on installing GD by CPAN.
I wrapped all the latest of zlib/libpng/jpeg/freetype/libgd/GD moudels and successfully installed GD on Mavericks (Mac OSX 10.9), hope this could help the one who have the similar environments.
Also works on Yosemite (OS X 10.10).
Note Xcode should be installed first (if you haven’t) and make sure you have a sudo privilege.
Download all the package here.
Extract the package gd.tar.gz and type sudo ./install to install.
This is an alternative approach:

curl -O http://wangqinhu.com/data/gd/gd.tar.gz
tar -zxf gd.tar.gz
cd gd
sudo ./install

Here is the script if you want to modify for your situation (also supplied in the package).

# Install zlib/libpng/jpeg/freetype/libgd/GD
# Wang Qinhu (qinhu.wang # gmail.com)
# Nov 17, 2013
# version 0.2
#install zlib
echo "><><><><><><><><><"
echo "Installing zlib"
echo "><><><><><><><><><"
tar -zxf zlib-1.2.8.tar.xz
cd zlib-1.2.8
sudo make install
cd ..
#install libpng
echo "><><><><><><><><><"
echo "Installing libpng"
echo "><><><><><><><><><"
#install jpegb
echo "><><><><><><><><><"
echo "Installing libjpeg"
echo "><><><><><><><><><"
tar -zxf jpegsrc.v9.tar.gz
cd jpeg-9
sudo make install
cd ..
#install freetype
echo "><><><><><><><><><"
echo "Installing freetype"
echo "><><><><><><><><><"
tar -zxf freetype-
cd freetype-
sudo make install
cd ..
#install libgd
echo "><><><><><><><><><"
echo "Installing libgd"
echo "><><><><><><><><><"
tar -zxf libgd-2.1.0.tar.xz
cd libgd-2.1.0
./configure --with-zlib=/usr/local --with-jpeg=/usr/local --with-png=/usr/local --with-freetype=/usr/local
sudo make install
cd ..
#install GD
echo "><><><><><><><><><"
echo "Installing GD"
echo "><><><><><><><><><"
tar -zxf GD-2.50.tar.gz
cd GD-2.50
perl Makefile.PL
sudo make install
cd ..
rm -rf zlib-1.2.8 libpng-1.6.6 jpeg-9 freetype- libgd-2.1.0 GD-2.50
echo "GD" | xargs -I MODULE perl -e 'print eval "use MODULE;1"?"\n\n\nOK\n\n\n":"\n\n\nFail\n\n\n"'