Closed mrbone closed 6 years ago
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
如果提示安装失败则需要检查是否安装了 commandline-tool
xcode-select --install
接下来安装
nvm 需要添加 export
到 bashrc/zshrc 中。
export NVM_DIR="$HOME/.nvm"
. "/usr/local/opt/nvm/nvm.sh"
brew install yarn --without-node
安装完之后需要使用 brew doctor
排查是否有错误。
配置热键
sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
要使用 oh-my-zsh 需要安装 zsh,并且将 zsh 配置成 $SHELL 变量
chsh -s $(which zsh)
$ git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions
在 ~/.zshrc
中开启 plugins
plugins=(
git
z
yarn
zsh-autosuggestions
)
brew install zsh-syntax-highlighting
在 ~/.zshrc
中添加
# zsh-highlight-syntax
source /usr/local/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
brew install python
如果已经有 python (默认都有)则需要安装 pip
sudo easy_install pip
如果安装了 python,则 easy_install
自动就有了pip install --user powerline-status
git clone https://github.com/powerline/fonts.git --depth=1
install.sh
。echo "\ue0b0 \u00b1 \ue0a0 \u27a6 \u2718 \u26a1 \u2699"
测试输出是否正常theme
为 agnoster
。export DEFAULT_USER=$(whoami)
隐藏掉样式前面的 user@machine
占位~/.oh-my-zsh/themes/agnoster.zsh-theme
替换为如下代码。# vim:ft=zsh ts=2 sw=2 sts=2
#
# agnoster's Theme - https://gist.github.com/3712874
# A Powerline-inspired theme for ZSH
#
# # README
#
# In order for this theme to render correctly, you will need a
# [Powerline-patched font](https://github.com/Lokaltog/powerline-fonts).
# Make sure you have a recent version: the code points that Powerline
# uses changed in 2012, and older versions will display incorrectly,
# in confusing ways.
#
# In addition, I recommend the
# [Solarized theme](https://github.com/altercation/solarized/) and, if you're
# using it on Mac OS X, [iTerm 2](http://www.iterm2.com/) over Terminal.app -
# it has significantly better color fidelity.
#
# # Goals
#
# The aim of this theme is to only show you *relevant* information. Like most
# prompts, it will only show git information when in a git working directory.
# However, it goes a step further: everything from the current user and
# hostname to whether the last call exited with an error to whether background
# jobs are running in this shell will all be displayed automatically when
# appropriate.
### Segment drawing
# A few utility functions to make it easy and re-usable to draw segmented prompts
CURRENT_BG='NONE'
# Special Powerline characters
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
# NOTE: This segment separator character is correct. In 2012, Powerline changed
# the code points they use for their special characters. This is the new code point.
# If this is not working for you, you probably have an old version of the
# Powerline-patched fonts installed. Download and install the new version.
# Do not submit PRs to change this unless you have reviewed the Powerline code point
# history and have new information.
# This is defined using a Unicode escape sequence so it is unambiguously readable, regardless of
# what font the user is viewing this source code in. Do not replace the
# escape sequence with a single literal character.
# Do not change this! Do not make it '\u2b80'; that is the old, wrong code point.
SEGMENT_SEPARATOR=$'\ue0b0'
}
# Begin a segment
# Takes two arguments, background and foreground. Both can be omitted,
# rendering default background/foreground.
prompt_segment() {
local bg fg
[[ -n $1 ]] && bg="%K{$1}" || bg="%k"
[[ -n $2 ]] && fg="%F{$2}" || fg="%f"
if [[ $CURRENT_BG != 'NONE' && $1 != $CURRENT_BG ]]; then
echo -n " %{$bg%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR%{$fg%} "
else
echo -n "%{$bg%}%{$fg%} "
fi
CURRENT_BG=$1
[[ -n $3 ]] && echo -n $3
}
# End the prompt, closing any open segments
prompt_end() {
if [[ -n $CURRENT_BG ]]; then
echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
else
echo -n "%{%k%}"
fi
echo -n "%{%f%}"
CURRENT_BG=''
}
### Prompt components
# Each component will draw itself, and hide itself if no information needs to be shown
# Context: user@hostname (who am I and where am I)
prompt_context() {
if [[ "$USER" != "$DEFAULT_USER" || -n "$SSH_CLIENT" ]]; then
prompt_segment black default "%(!.%{%F{yellow}%}.)$USER@%m"
fi
}
# Git: branch/detached head, dirty status
prompt_git() {
local PL_BRANCH_CHAR
() {
local LC_ALL="" LC_CTYPE="en_US.UTF-8"
PL_BRANCH_CHAR=$'\ue0a0' #
}
local ref dirty mode repo_path
repo_path=$(git rev-parse --git-dir 2>/dev/null)
if $(git rev-parse --is-inside-work-tree >/dev/null 2>&1); then
dirty=$(parse_git_dirty)
ref=$(git symbolic-ref HEAD 2> /dev/null) || ref="➦ $(git rev-parse --short HEAD 2> /dev/null)"
if [[ -n $dirty ]]; then
prompt_segment yellow black
else
prompt_segment green black
fi
if [[ -e "${repo_path}/BISECT_LOG" ]]; then
mode=" <B>"
elif [[ -e "${repo_path}/MERGE_HEAD" ]]; then
mode=" >M<"
elif [[ -e "${repo_path}/rebase" || -e "${repo_path}/rebase-apply" || -e "${repo_path}/rebase-merge" || -e "${repo_path}/../.dotest" ]]; then
mode=" >R>"
fi
setopt promptsubst
autoload -Uz vcs_info
zstyle ':vcs_info:*' enable git
zstyle ':vcs_info:*' get-revision true
zstyle ':vcs_info:*' check-for-changes true
zstyle ':vcs_info:*' stagedstr '✚'
zstyle ':vcs_info:*' unstagedstr '●'
zstyle ':vcs_info:*' formats ' %u%c'
zstyle ':vcs_info:*' actionformats ' %u%c'
vcs_info
echo -n "${ref/refs\/heads\//$PL_BRANCH_CHAR }${vcs_info_msg_0_%% }${mode}"
fi
}
prompt_hg() {
local rev status
if $(hg id >/dev/null 2>&1); then
if $(hg prompt >/dev/null 2>&1); then
if [[ $(hg prompt "{status|unknown}") = "?" ]]; then
# if files are not added
prompt_segment red white
st='±'
elif [[ -n $(hg prompt "{status|modified}") ]]; then
# if any modification
prompt_segment yellow black
st='±'
else
# if working copy is clean
prompt_segment green black
fi
echo -n $(hg prompt "☿ {rev}@{branch}") $st
else
st=""
rev=$(hg id -n 2>/dev/null | sed 's/[^-0-9]//g')
branch=$(hg id -b 2>/dev/null)
if `hg st | grep -q "^\?"`; then
prompt_segment red black
st='±'
elif `hg st | grep -q "^[MA]"`; then
prompt_segment yellow black
st='±'
else
prompt_segment green black
fi
echo -n "☿ $rev@$branch" $st
fi
fi
}
# Dir: current working directory
prompt_dir() {
prompt_segment blue black '%~'
}
# Virtualenv: current working virtualenv
prompt_virtualenv() {
local virtualenv_path="$VIRTUAL_ENV"
if [[ -n $virtualenv_path && -n $VIRTUAL_ENV_DISABLE_PROMPT ]]; then
prompt_segment blue black "(`basename $virtualenv_path`)"
fi
}
# Status:
# - was there an error
# - am I root
# - are there background jobs?
prompt_status() {
local symbols
symbols=()
[[ $RETVAL -ne 0 ]] && symbols+="%{%F{red}%}✘"
[[ $UID -eq 0 ]] && symbols+="%{%F{yellow}%}⚡"
[[ $(jobs -l | wc -l) -gt 0 ]] && symbols+="%{%F{cyan}%}⚙"
[[ -n "$symbols" ]] && prompt_segment black default "$symbols"
}
prompt_newline() {
if [[ -n $CURRENT_BG ]]; then
echo -n " %{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR
%{%k%F{$CURRENT_BG}%}$SEGMENT_SEPARATOR"
else
echo -n " %{%k%}"
fi
echo -n " %{%f%}"
CURRENT_BG=''
}
## Main prompt
build_prompt() {
RETVAL=$?
prompt_status
prompt_virtualenv
prompt_context
prompt_dir
prompt_git
prompt_hg
prompt_newline
prompt_end
}
PROMPT='%{%f%b%k%}$(build_prompt)'
同样需要安装 Powerline fonts
git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k
修改 ~/.zshrc
中
ZSH_THEME="powerlevel9k/powerlevel9k"
#powerlevel9k
POWERLEVEL9K_PROMPT_ADD_NEWLINE=true
POWERLEVEL9K_PROMPT_ON_NEWLINE=true
POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(dir rbenv vcs)
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(status root_indicator background_jobs history time)
# folder
alias cdwk="cd /Users/mrbone/Workspace"
alias cdsl="cd /Users/mrbone/Workspace/github/self-learning"
alias cdsw="cd /Users/mrbone/Workspace/github/self-written"
alias qksl="code /Users/mrbone/Workspace/github/self-learning"
alias qksw="code /Users/mrbone/Workspace/github/self-written"
后记: 还是换回 box 了。
iTerm2 → Preferences → Profiles → Text
→ Cursor : ✓ Vertical Bar
→ Blinking cursor: ✓ ON
iterm2
中敲 CMD+i 配置,选择 color -> import -> 选择刚才下载的 schema 目录下对应的颜色 preset (目前使用的是 Later This Evening)14pt Meslo LG M DZ Regular for powerline
iTerm → Preferences → Profiles → Keys → Load Preset… → Natural Text Editing
on run {input, parameters}
tell application "Finder"
set dir_path to quoted form of (POSIX path of (folder of the front window as alias))
end tell
CD_to(dir_path)
end run
on CD_to(theDir)
tell application "iTerm"
activate
set win to (create window with default profile)
set sesh to (current session of win)
tell sesh to write text "cd " & theDir & ";clear"
end tell
end CD_to
iTermOpenScript.app
拖到标题栏,同时按住 options
+ command
能够调整图标在标题栏的位置。{
// Place your snippets for javascriptreact here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "lg",
"body": [
"console.log('$1');",
],
"description": "Log output to console"
},
"Import Module": {
"prefix": "imp",
"body": [
"import ${0:module} from '$1';"
],
"description": "import a dependency"
},
"Arrow function": {
"prefix": "a>",
"body": [
"($1) => {",
" $0",
"}"
],
"description": "Insert an arrow function"
},
"New React PureComponent": {
"prefix": "react:pure",
"body": [
"import React from 'react';",
"",
"class ${1:ComponentName} extends React.PureComponent {",
" render(){",
" return $0",
" }",
"}",
"export default ${1:ComponentName};"
],
"description": "Quickly create a fresh new react PureComponent"
},
"New React Component": {
"prefix": "react:normal",
"body": [
"import React from 'react';",
"",
"class ${1:ComponentName} extends React.Component {",
" render(){",
" return $0",
" }",
"}",
"export default ${1:ComponentName};"
],
"description": "Quickly create a fresh new react Component"
},
"New React Stateless Component": {
"prefix": "react:statelss",
"body": [
"import React from 'react';",
"",
"const ${1:ComponentName} = () => {",
" return ($0)",
"};",
"export default ${1:ComponentName};"
],
"description": "Quickly create a fresh new react Component"
},
"Create React elemnt": {
"prefix": "react:element",
"body":[
"<${1:ComponentName}>",
" $0",
"</${1:ComponentName}>"
],
"description": "create a react element with double close"
},
"Create React elemnt with single close tag": {
"prefix": "react:element-single",
"body":[
"<${0:ComponentName} />",
],
"description": "create a react element with single close tag"
},
"Deconstruct component props or state": {
"prefix": "const:react",
"body":[
"const { $0 } = this.${1:props};",
],
"description": "deconstruct component props or state"
}
}
{
// Place your snippets for javascript here. Each snippet is defined under a snippet name and has a prefix, body and
// description. The prefix is what is used to trigger the snippet and the body will be expanded and inserted. Possible variables are:
// $1, $2 for tab stops, $0 for the final cursor position, and ${1:label}, ${2:another} for placeholders. Placeholders with the
// same ids are connected.
// Example:
"Print to console": {
"prefix": "lg",
"body": [
"console.log($1);",
],
"description": "Log output to console"
},
"Arrow function": {
"prefix": "a>",
"body": [
"($1) => {",
" $0",
"}"
],
"description": "Insert an arrow function"
},
"Import Module": {
"prefix": "imp",
"body": [
"import ${0:module} from '$1';"
],
"description": "import a dependency"
},
"New React PureComponent": {
"prefix": "react:pure",
"body": [
"import React from 'react';",
"",
"class ${1:ComponentName} extends React.PureComponent {",
" render(){",
" return $0",
" }",
"}",
"export default ${1:ComponentName};"
],
"description": "Quickly create a fresh new react PureComponent"
},
"New React Component": {
"prefix": "react:normal",
"body": [
"import React from 'react';",
"",
"class ${1:ComponentName} extends React.Component {",
" render(){",
" return $0",
" }",
"}",
"export default ${1:ComponentName};"
],
"description": "Quickly create a fresh new react Component"
},
"New React Stateless Component": {
"prefix": "react:statelss",
"body": [
"import React from 'react';",
"const ${1:ComponentName} = () => {",
" return ($0)",
"};",
"export default ${1:ComponentName};"
],
"description": "Quickly create a fresh new react Component"
},
"Create React elemnt": {
"prefix": "react:element",
"body":[
"<${0:ComponentName}>",
"",
"</${0:ComponentName}>"
],
"description": "create a react element with double close"
},
"Create React elemnt with single close tag": {
"prefix": "react:element-single",
"body":[
"<${0:ComponentName} />",
],
"description": "create a react element with single close tag"
}
}
{
"workbench.iconTheme": "vscode-icons",
"explorer.confirmDragAndDrop": false,
"explorer.confirmDelete": false,
"vsicons.projectDetection.autoReload": true,
"javascript.implicitProjectConfig.experimentalDecorators": true,
"editor.tabSize": 2,
"window.title": "${activeEditorMedium}",
"relativePath.removeExtension": true,
"explorer.autoReveal": true
}
在 Rime (/Users/cbxu/Library/Rime) 目录下新建 default.custom.yaml
文件,添加配置:
patch:
"menu/page_size": 9
对应程序关闭中文输入: 新建 squirrel.custom.yaml
,对应程序的 name 在 app content 中的 Info.plist
Identifier 字段中查看
patch:
app_options/com.microsoft.VSCode:
ascii_mode: true
app_options/com.jetbrains.WebStorm:
ascii_mode: true
app_options/com.google.Chrome:
ascii_mode: true
app_options/com.cerebroapp.Cerebro:
ascii_mode: true
app_options/com.googlecode.iterm2:
ascii_mode: true
app_options/com.youdao.YoudaoDict:
ascii_mode: true
app_options/com.runningwithcrayons.Alfred-3:
ascii_mode: true
第一个免费版只能保存 3 个历史记录。
ssh-keygen -t rsa -C "your.email@example.com" -b 4096
Cmd+Shift+3:全屏截图;截取整个屏幕,保存截图至桌面文件夹。Cmd+Shift+4:区域截图;鼠标光标变成带坐标的小十字,通过拖拽截取特定区域,保存截图至桌面文件夹。Cmd+Shift+4 - 单击空格键 - 鼠标单击指定窗口:窗口截图;出现小十字光标后对指定窗口按空格键,鼠标光标变成照相机,鼠标单击截取指定窗口,保存截图至桌面文件夹。进阶快捷键Cmd+Shift+4 - 按住空格键拖动鼠标:区域截图;选取区域范围后,按住空格键并拖到鼠标可移动选取范围,释放按键后保存截图至桌面文件夹。Cmd+Shift+4 - 按住Shift - 上下/左右移动鼠标:区域截图;选取区域范围后,按住 Shift 并上下/左右移动鼠标即可固定选取范围宽度/高度改变高度/宽度,释放按键后保存截图至桌面文件夹。Cmd+Shift+4 - 按住Shift和Option: 区域截图;选取区域范围后,按住 Shift 和 Option 键在上一快捷键功能的基础上自由切换高度宽度,释放按键后保存截图至桌面文件夹。Cmd+Shift+4 - 按住Option: 区域截图;选取区域范围后,按住 Option 键可按比例缩放选取范围,释放按键后保存截图至桌面文件夹。PS:以上介绍的快捷键配合按住 Control 键即可将截图文件保存在剪切板,以供调用。
查看当前蓝牙状态
sudo defaults read bluetoothaudiod
开启 aptx
sudo defaults write bluetoothaudiod "Enable AptX codec" -bool true
开启 aac
sudo defaults write bluetoothaudiod "Enable AAC codec" -bool true
https://github.com/bhilburn/powerlevel9k/wiki/Stylizing-Your-Prompt
https://github.com/bhilburn/powerlevel9k/wiki/Show-Off-Your-Config
创建此卡的目的
记录必需的基本软件和配置
简单的描述
验收点
可以基本进入开发状态