Skip to content

Instantly share code, notes, and snippets.

@rambolee
Last active October 25, 2016 10:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rambolee/0f250918b5aecbe264ea8557c8b8c16c to your computer and use it in GitHub Desktop.
Save rambolee/0f250918b5aecbe264ea8557c8b8c16c to your computer and use it in GitHub Desktop.
Mac 基础使用环境初始化(一)

Mac 基础使用环境初始化(一)

Console 相关

homebrew 安装

http://brew.sh/index_zh-cn.html

清华大学镜像: 参考 https://mirrors.tuna.tsinghua.edu.cn/help/homebrew/

安装 brew cask

cd /usr/local
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/brew.git

cd /usr/local/Library/Taps/homebrew/homebrew-core
git remote set-url origin https://mirrors.tuna.tsinghua.edu.cn/git/homebrew-core.git

brew update

zsh on-my-zsh

新系统可能没有 wget 可以 homebrew 安装一下 wget

wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh

修改 oh-my-zsh theme dst

vi ~/.zshrc  

===
ZSH_THEME="dst"

配置 plugins .zshrc

plugins=(git autojump) [[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh

iterm2

create new profile for work:

libo@localhost: ~
 $ cat /usr/local/bin/login.exp                                                                                              [11:10:14]
#!/usr/bin/expect
# 参数1:远程host;参数2:远程password
#if { $argc != 2 } {
#    send_user "Usage: host password\n"
#    exit
#}

#set host [lindex $argv 0]
#set pw [lindex $argv 1]

set TERMSERV 123.59.122.11
set TERMSERVPORT 50022
set USER libo17
set PASSWORD {$password}
set VMHOST 10.185.30.240
set ROOTPASSWD {$password}

# 登录跳板机
catch {spawn ssh -l $USER $TERMSERV -p $TERMSERVPORT}
expect "*assword:*" { send "$PASSWORD\r";}

expect "*Type*" {send ":";}
expect ":" {send "ssh root@$VMHOST\r";}
expect "*assword:*" { send "$ROOTPASSWD\r";}
expect "*$VMHOST*" { send "cd ~; ./itmux.sh; cd /home/wwwroot\r"; interact }
chmod +x /usr/local/bin/login.exp

set iterm2 with new profile: iterm2_profile

可以配置一下 window的默认打开 size

set iTerm2 lrzsz

brew install lrzsz

vi iterm2-recv-zmodem.sh
#!/bin/bash
#Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain

FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose folder with prompt "Choose a folder to place received files in"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
if [[ $FILE = "" ]]; then
  echo Cancelled.
  # Send ZModem cancel
  echo -e \\x18\\x18\\x18\\x18\\x18
  echo \# Cancelled transfer
  echo
else
  echo $FILE
  cd "$FILE"
  /usr/local/bin/lrz
  echo \# Received $FILE
  echo
fi


vi itemr2-send-zmodem.sh

#!/bin/bash
#Author: Matt Mastracci (matthew@mastracci.com)
# AppleScript from http://stackoverflow.com/questions/4309087/cancel-button-on-osascript-in-a-bash-script
# licensed under cc-wiki with attribution required
# Remainder of script public domain

FILE=`osascript -e 'tell application "iTerm" to activate' -e 'tell application "iTerm" to set thefile to choose file with prompt "Choose a file to send"' -e "do shell script (\"echo \"&(quoted form of POSIX path of thefile as Unicode text)&\"\")"`
if [[ $FILE = "" ]]; then
  echo Cancelled.
  # Send ZModem cancel
  echo -e \\x18\\x18\\x18\\x18\\x18
  echo \# Cancelled transfer
  echo
else
  echo $FILE
  /usr/local/bin/lsz "$FILE"
  echo \# Received $FILE
  echo
fi


chmod +x iterm2-recv-zmodem.sh iterm2-send-zmodem.sh

configuration iTerm2 default trigger default trigger(iTerm偏好设置-> Profiles –> Default –> Advanced –> Triggers的Edit按钮

Regular expression: \*\*B0100 
Action: Run Silent Coprocess 
Parameters: /usr/local/bin/iterm2-send-zmodem.sh


Regular expression: \*\*B00000000000000 
Action: Run Silent Coprocess 
Parameters: /usr/local/bin/iterm2-recv-zmodem.sh

set iTerm2 session clone iTerm2也支持类似secureCRT所提供的克隆会话的问题,对服务端码龙而言是很方便的,可以避免输入密码。 通过下面步骤就可以实现该功能。

1) 配置Mac所在机器的ssh。 vi ~/.ssh/config 输入下面三行 host * ControlMaster auto ControlPath ~/.ssh/master-%r@%h:%p

2)第一次远程服务器,还是需要输入密码 例如:ssh server00_name

  1. ssh成功后,使用快捷键command + t 产生一个新的窗口 然后再次 ssh 你的远程服务器。 就不用输入密码了,达到克隆会话的效果。

sublime text 3

参考「sublime text 3 configuration notes」

安装 marp

brew cask install marp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment