brew 是 Mac 下的一个包管理工具,类似于 centos 下的 yum,可以很方便地进行安装/卸载/更新各种软件包,例如:nodejs, elasticsearch, kibana, mysql, mongodb 等等,可以用来快速搭建各种本地环境,程序员必备工具
首先要通过如下命令安装 brew
/usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”
1
基本用法
安装/卸载/更新
以 nodejs 为例,执行下面命令即可,安装目录在 /usr/local/Cellar
brew install nodejs
1
如果需要更新或卸载
brew upgrade nodejs
brew remove nodejs
1
2
其他命令
brew list # 列出当前安装的软件
brew search nodejs # 查询与 nodejs 相关的可用软件
brew info nodejs # 查询 nodejs 的安装信息
1
2
3
如果需要指定版本,可以在 brew search 查看有没有需要的版本,在 @ 后面指定版本号,例如 brew install [email protected]
brew services
brew services 是一个非常强大的工具,可以用来管理各种服务的启停,有点像 linux 里面的 services,非常方便,以 elasticsearch 为例
brew install elasticsearch # 安装 elasticsearch
brew services start elasticsearch # 启动 elasticsearch
brew services stop elasticsearch # 停止 elasticsearch
brew services restart elasticsearch # 重启 elasticsearch
brew services list # 列出当前的状态
1
2
3
4
5
brew services 服务相关配置以及日志路径
配置路径:/usr/local/etc/
日志路径:/usr/local/var/log
参考链接
brew 官网:https://brew.sh/
转载请注明出处
本文链接:http://hatlonely.github.io/2018/02/21/Mac-必备工具之-brew/
1,mac自带的ctags程序不是exuberant ctags, 所以使用时会出现问题,所以要重新安装一个;
brew install exuberant ctags
安装完, which ctags
如果是/usr/bin/ctags,系统默认先看到我们安装的ctags
打开~/根目录下的.profile,如果你也没发现有这个文件,没关系,创建一个!
然后在里面添加:export PATH="/usr/local/bin:/usr/local/sbin:$PATH"
再到终端执行:source ~/.profile
然后再看看which ctags,如无意外,应该是/usr/local/bin/ctags
最后在.vimrc配置文件添加:
let Tlist_Ctags_Cmd="/usr/local/bin/ctags"
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow=1
let Tlist_Use_Right_Window=1
2、使用ctags编译项目tags文件
终端cd 项目目录,然后执行:
ctags -R
你会发现目录中多了一个tags的文件,这个就是vim里面taglist会寻找的文件!
在vim中对准某个对象调用的方法按control + ] 看看能否调到那个方法的定义!?
control + t 返回原方法
brew install cscope.
cscope将被安装在/usr/local/bin/文件夹下。
MAC电脑不装 BREW工具,就是买枪不买子弹啊!
"------------------------------------------------------------------------------
" Vundle
"------------------------------------------------------------------------------
" set the runtime path to include Vundle and initialize
set nocompatible " be iMproved, required
filetype off " required
" set the runtime path to include Vundle and initialize
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" let Vundle manage Vundle, required
Plugin 'VundleVim/Vundle.vim'
Plugin 'flazz/vim-colorschemes'
"""""""" vim scripts """"""""""""""""""
Plugin 'vim-scripts/taglist.vim'
Plugin 'vim-scripts/c.vim'
Plugin 'vim-scripts/minibufexpl.vim'
Plugin 'vim-scripts/comments.vim'
Plugin 'vim-scripts/winmanager'
"""""""" git script """""""""""""""""""
Plugin 'scrooloose/nerdtree'
Plugin 'Valloric/YouCompleteMe'
Plugin 'scrooloose/syntastic'
Plugin 'Lokaltog/vim-powerline'
" All of your Plugins must be added before the following line
call vundle#end() " required
filetype plugin indent on " required
" To ignore plugin indent changes, instead use:
"filetype plugin on
"
" Brief help
" :PluginList - lists configured plugins
" :PluginInstall - installs plugins; append `!` to update or just :PluginUpdate
" :PluginSearch foo - searches for foo; append `!` to refresh local cache
" :PluginClean - confirms removal of unused plugins; append `!` to auto-approve removal
"
" see :h vundle for more details or wiki for FAQ
" Put your non-Plugin stuff after this line
"------------------------------------------------------------------------------
" nerdtree settings
"------------------------------------------------------------------------------
"autocmd vimenter * NERDTree
map <F2> :NERDTreeToggle<CR>
autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif
map <silent> <F2> :NERDTreeToggle<CR>
autocmd bufenter * if (winnr("$") == 1 && exists("b:NERDTreeType") && b:NERDTreeType == "primary") | q | endif
"------------------------------------------------------------------------------
" ctags settings
"------------------------------------------------------------------------------
let Tlist_Ctags_Cmd ='/usr/local/Cellar/ctags/5.8_1/bin/ctags'
"let g:molokai_original = 1
"let g:rehash256 = 1
"colorscheme molokai
"------------------------------------------------------------------------------
" syntastic setting
"------------------------------------------------------------------------------
let g:syntastic_check_on_open = 1
let g:syntastic_lua_checkers = ['lua', 'luac']
"------------------------------------------------------------------------------
" Powerline setting
"------------------------------------------------------------------------------
set laststatus=2
let g:Powerline_symbols='unicode'
"set foldenable
"set foldnestmax=1
"set foldmethod=syntax
"------------------------------------------------------------------------------
" YouCompleteMe setting
"------------------------------------------------------------------------------
let g:ycm_global_ycm_extra_conf = '~/.vim/bundle/YouCompleteMe/third_party/ycmd/cpp/ycm/.ycm_extra_conf.py'
"let g:ycm_error_symbol = '>>'
"let g:ycm_warning_symbol = '>*'
nnoremap <leader>gl :YcmCompleter GoToDeclaration<CR>
nnoremap <leader>gf :YcmCompleter GoToDefinition<CR>
nnoremap <leader>gg :YcmCompleter GoToDefinitionElseDeclaration<CR>
nnoremap <leader>jd :YcmCompleter GoToDefinitionElseDeclaration<CR>
nmap <F4> :YcmDiags<CR>
set completeopt=longest,menu
autocmd InsertLeave * if pumvisible() == 0|pclose|endif
inoremap <expr> <CR> pumvisible() ? "\" : "\"
inoremap <expr> <Down> pumvisible() ? "\" : "\"
inoremap <expr> <Up> pumvisible() ? "\" : "\"
inoremap <expr> <PageDown> pumvisible() ? "\\\" : "\"
inoremap <expr> <PageUp> pumvisible() ? "\\\" : "\"
let g:ycm_key_list_select_completion = ['' ]
let g:ycm_key_list_previous_completion = ['' ]
let g:ycm_confirm_extra_conf=0
let g:ycm_collect_identifiers_from_tags_files=1
let g:ycm_min_num_of_chars_for_completion=2
let g:ycm_cache_omnifunc=0
let g:ycm_seed_identifiers_with_syntax=1
nnoremap <F5> :YcmForceCompileAndDiagnostics<CR>
"force recomile with syntastic
inoremap <leader><leader> <C-x><C-o>
let g:ycm_complete_in_comments = 1
let g:ycm_complete_in_strings = 1
let g:ycm_collect_identifiers_from_comments_and_strings = 0
"------------------------------------------------------------------------------
" TagList :Tlist
"------------------------------------------------------------------------------
let Tlist_Show_One_File=1
let Tlist_Exit_OnlyWindow = 1
let Tlist_Ctags_Cmd="/usr/bin/ctags"
"------------------------------------------------------------------------------
" WinManager Setting
"------------------------------------------------------------------------------
let g:winManagerWindowLayout='NERDTree|TagList'
let g:winManagerWidth=30
"let g:AutoOpenWinManager = 1
nmap wm :WMToggle<cr>
"------------------------------------------------------------------------------
" settings
"------------------------------------------------------------------------------
set nocompatible " be iMproved, required
filetype off " required
" Set syntax highlighting for specific file types
autocmd BufRead,BufNewFile *.md set filetype=markdown
" color scheme
colorscheme molokai
" Backspace deletes like most programs in insert mode
set backspace=2
" Show the cursor position all the time
set ruler
" Display incomplete commands
set showcmd
" Set fileencodings
set fileencodings=ucs-bom,utf-8,cp936,gb2312,gb18030,big5
set background=dark
set encoding=utf-8
set fenc=utf-8
set smartindent
set autoindent
set cul
set linespace=2
set showmatch
set lines=47 columns=90
set transparency=7
" Numbers
set number
"set numberwidth=5
" font and size
"set guifont=Andale Mono:h14
"set guifont=Monaco:h11
set guifont=Menlo:h14
" Softtabs, 2 spaces
set tabstop=2
set shiftwidth=2
set shiftround
set softtabstop=2
set expandtab
set smarttab
" Display extra whitespace
"set list listchars=tab:»·,trail:·
"set list listchars=tab:-·,trail:·
" Make it obvious where 80 characters is
set textwidth=80
set colorcolumn=+1
" Highlight current line
au WinLeave * set nocursorline
au WinEnter * set cursorline
set cursorline
if has("gui_running")
set guioptions-=m
set guioptions-=T
set guioptions-=L
set guioptions-=r
set guioptions-=b
set showtabline=0
endif
if has('mouse')
set mouse=a
endif
if &t_Co > 2 || has("gui_running")
syntax on
endif