mac git stash changes_Mac终端iTerm2美化教程

安装Homebrew

终端执行代码:

 /usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

或者去Homebrew官网查看安装命令

一般会自动安装Command Line Tools for Xcode(安装Homebrew必需的插件)

Homebrew常用语句

搜索:brew search

更新:brew install

卸载:brew uninstall

显示已安装软件: brew ls(list)

显示软件的信息:brew info

Homebrew其他使用命令可以参考 https://www.jianshu.com/p/de6f1d2d37bf

使用brew services管理服务开机启动

GitHub: https://github.com/Homebrew/homebrew-services

一般macOS使软件开机自启的命令一般是 launchctl命令加载开机自动运行服务,使用brew service可以简化操作。

  • launchctl的配置方式,以MySQL为例:
 ln -sfv /usr/local/opt/mysql/*.plist ~/Library/LaunchAgents launchctl load ~/Library/LaunchAgents/homebrew.mxcl.mysql.plist
  • 如使用brew service可以简化为:
 brew services start mysql
f5f202cff510d9535d66821bd17712de.png

常用命令

 brew services list # 查看使用brew安装的服务列表 brew services run formula|--all # 启动服务(仅启动不注册) brew services start formula|--all # 启动服务,并注册开机启动 brew services stop formula|--all # 停止服务,并取消注册开机启动 brew services restart formula|--all # 重启服务,并注册开机启动 brew services cleanup # 清除已卸载应用的无用的配置

.plist配置文件存放目录

  1. 开机自启存放目录,需要sudo
 /Library/LaunchDaemons
  1. 用户登录后自启存放目录
 ~/Library/LaunchAgents

可以在homebrew.mxcl.kafka.plist文件中找到服务路径、启动参数、日志路径等

安装ZSH

  1. 直接用Homebrew安装zsh:
 brew install zsh
  1. 接着使zsh生效
  2. 先使用命令
 cat /etc/shells
  1. 查看/etc/shells文件中有没有
 /usr/local/bin/zsh 或者 /bin/zsh
  1. 如果没有就用vim /etc/shells加上;如果有,就执行下一命令使zsh生效:
 chsh -s /usr/local/bin/zsh 或者 chsh -s /bin/zsh
  1. 安装oh-my-zsh
  2. 安装oh-my-zsh需要使用git工具,先安装git:
 brew install git
  1. 在执行以下代码:(如果失效,可以去查看oh-my-zsh开源项目)
  2. via curl
 sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
  1. via wget
 sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"
  1. 最终效果如图:
f2960e7851a5dc0bf10bfedb7d680436.png
  1. 关于配置文件
  2. 默认Shell的~/.bashrc文件默认不再加载了,替代的是~/.zlogin和~/.zshrc。

配置Mac终端iTerm2(powerlevel9k)

经过以上配置已经很完美了

现在缺少一个很漂亮的主题

首先创建一个暂存文件夹,然后进入这个文件夹,在克隆iTerm2的配色方案,依次执行以下三行代码:

 mkdir tmp cd tmp git clone https://github.com/MartinSeeler/iterm2-material-design.git

然后在该目录双击'material-design-colors.itermcolors'文件,点确定!

然后rm -rf删库跑路(tmp)

 cd .. rm -rf tmp/

打开iTerm2 command+, 打开设置->Profiles->Colors->Color Presets->material-design-colors->command+W

安装powerlevel9k:

 git clone https://github.com/bhilburn/powerlevel9k.git ~/.oh-my-zsh/custom/themes/powerlevel9k

修改 ~/.zshrc 配置文件,配置该主题

 vim ~/.zshrc

在里面设置主题

 ZSH_THEME="powerlevel9k/powerlevel9k"

重启终端,会发现有些字符显示乱码

9524af990f68171cd78b976393f93031.png

这时候需要安装Nerd字体

安装可能很慢可以使用以下安装命令:

 cd ~/Library/Fonts && curl -fLo "Droid Sans Mono for Powerline Nerd Font Complete.otf" https://github.com/ryanoasis/nerd-fonts/raw/master/patched-fonts/DroidSansMono/complete/Droid%20Sans%20Mono%20Nerd%20Font%20Complete.otf

安装完字体后更改iTerm2终端字体 搜索nerd选择就行了

安装成功后就是这样的:

b9d0eef205edc2e264d3d5ad72e47bcc.png

接下来配置powerlevel9k主题

 vim ~/.zshrc

在主题ZSH_THEME=xxxxxxx前面加上

 POWERLEVEL9K_MODE="nerdfont-complete"

在最后添加以下内容:

 # ================= powerlevel9k Settings ================= # Please only use this battery segment if you have material icons in your nerd font (or font) # Otherwise, use the font awesome one in "User Segments" ​ POWERLEVEL9K_PROMPT_ON_NEWLINE=true POWERLEVEL9K_PROMPT_ADD_NEWLINE=true POWERLEVEL9K_RPROMPT_ON_NEWLINE=true POWERLEVEL9K_SHORTEN_DIR_LENGTH=2 POWERLEVEL9K_SHORTEN_STRATEGY="truncate_beginning" POWERLEVEL9K_RVM_BACKGROUND="black" POWERLEVEL9K_RVM_FOREGROUND="249" POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_COLOR="red" POWERLEVEL9K_TIME_BACKGROUND="black" POWERLEVEL9K_TIME_FOREGROUND="249" POWERLEVEL9K_TIME_FORMAT=" %D{%I:%M  %m.%d.%y}" POWERLEVEL9K_RVM_BACKGROUND="black" POWERLEVEL9K_RVM_FOREGROUND="249" POWERLEVEL9K_RVM_VISUAL_IDENTIFIER_COLOR="red" POWERLEVEL9K_STATUS_VERBOSE=false POWERLEVEL9K_VCS_CLEAN_FOREGROUND='black' POWERLEVEL9K_VCS_CLEAN_BACKGROUND='green' POWERLEVEL9K_VCS_UNTRACKED_FOREGROUND='black' POWERLEVEL9K_VCS_UNTRACKED_BACKGROUND='yellow' POWERLEVEL9K_VCS_MODIFIED_FOREGROUND='white' POWERLEVEL9K_VCS_MODIFIED_BACKGROUND='black' POWERLEVEL9K_COMMAND_EXECUTION_TIME_BACKGROUND='black' POWERLEVEL9K_COMMAND_EXECUTION_TIME_FOREGROUND='blue' POWERLEVEL9K_FOLDER_ICON='' POWERLEVEL9K_STATUS_OK_IN_NON_VERBOSE=true POWERLEVEL9K_STATUS_VERBOSE=false POWERLEVEL9K_COMMAND_EXECUTION_TIME_THRESHOLD=0 POWERLEVEL9K_VCS_UNTRACKED_ICON='●' POWERLEVEL9K_VCS_UNSTAGED_ICON='±' POWERLEVEL9K_VCS_INCOMING_CHANGES_ICON='↓' POWERLEVEL9K_VCS_OUTGOING_CHANGES_ICON='↑' POWERLEVEL9K_VCS_COMMIT_ICON="" POWERLEVEL9K_MULTILINE_FIRST_PROMPT_PREFIX="%F{blue}╭─%f" POWERLEVEL9K_MULTILINE_LAST_PROMPT_PREFIX="%F{blue}╰%f " POWERLEVEL9K_CUSTOM_BATTERY_STATUS="prompt_zsh_battery_level" POWERLEVEL9K_LEFT_PROMPT_ELEMENTS=(context os_icon custom_internet_signal custom_battery_status_joined ssh root_indicator dir dir_writable vcs) POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(command_execution_time status time) HIST_STAMPS="mm/dd/yyyy" DISABLE_UPDATE_PROMPT=true

最终显示效果:

2ed60e8f1f8354bdb868ca9a6cf1b452.png

再安装两个插件:

安装 autosuggestions(自动提示)

 git clone https://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

安装 syntax-highlighting(动态高亮)

 git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

在配置文件里启用插件:

vim ~/.zshrc

 plugins=( git zsh-autosuggestions zsh-syntax-highlighting ) # 注意:zsh-syntax-highlighting 必须放在最后面(官方推荐)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值