oh my zshshell的类型有很多种,linux下默认的是bash,虽然bash的功能已经很强大,但对于以懒惰为美德的程序员来说,bash的提示功能不够强大,界面也不够炫,并非理想工具。 而zsh的功能极其强大,只是配置过于复杂,起初只有极客才在用。后来,有个穷极无聊的程序员可能是实在看不下去广大猿友一直只能使用单调的bash, 于是他创建了一个名为 自此,只需要简单的安装配置,小白程序员们都可以用上高档大气上档次,狂拽炫酷吊炸天的 安装zsh以ubuntu 16.04为例: 查看系统当前使用的shell $ echo $SHELL /bin/bash 查看系统是否安装了zsh $ cat /etc/shells /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin /bin/tcsh /bin/csh
用yum安装zsh $ yum -y install zsh 查看shell列表 $ cat /etc/shells /bin/sh /bin/bash /sbin/nologin /usr/bin/sh /usr/bin/bash /usr/sbin/nologin /bin/tcsh /bin/csh /bin/zsh 切换shell为zsh $ chsh -s /bin/zshChanging shell for root.Shell changed. 重启服务器后,可使用 重启后,查看当前shell $ echo $SHELL /bin/zsh 安装 oh my zshoh-my-zsh源码是放在github上,先确保你的机器上已安装了git 安装: wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | sh 成功界面: ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ \ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed!Please look over the ~/.zshrc file to select plugins, themes, and options.p.s. Follow us at https://twitter.com/ohmyzsh.p.p.s. Get stickers and t-shirts at http://shop.. 接下来只需简单的配置,就可以享受 主题选择oh-my-zsh有很多漂亮的主题: 我使用的主题是 http://blog./my-ys-terminal-theme/ 修改主题: $ vim ~/.zshrc 将 ZSH_THEME="ys" 更新配置: $ source ~/.zshrc 自动补齐插件linux不少命令的参数很多,不可能一一记住,常规的查看手册又觉得慢。如果你也有这种苦恼,那么我相信你会爱上 一图胜千言 下载此插件: $ wget http:///src/incr-0.2.zsh 将此插件放到oh-my-zsh目录的插件库下: # root @ linux in ~/.oh-my-zsh/plugins/incr on git:master x [15:05:07] $ ls root@linux incr-0.2.zsh 在 source ~/.oh-my-zsh/plugins/incr/incr*.zsh 更新配置: $ source ~/.zshrc 接下来你就可以体验到 与vim的提示相冲突的解决方案使用自动补全插件可能会与vim的提示功能相冲突,如会报以下错误: $ vim t _arguments:451: _vim_files: function definition file not found 解决方法:将 $ rm -rf ~/.zcompdump* $ exec zsh 这时你需要安装: # sudo apt-get install libssl-dev 当wget出现 Can’t connect to HTTPS URL because the SSL module is not available 你需要安装: # sudo apt-get install openssl 正在解析主机 raw. (raw.)... 0.0.0.0 正在连接 raw. (raw.)|0.0.0.0|:443... 失败: 解决办法 原因就是https://raw./ohmyzsh/ohmyzsh/master/tools/install.sh这个网站是被墙的。 开一个梯子,打开https://raw./ohmyzsh/ohmyzsh/master/tools/install.sh保存此脚本到本机。 执行sudo sh ./install.sh,看到如下界面表示安装成功了。 闲麻烦不想配置hosts,也可以直接执行下面这些命令,把这些命令拷贝到sh文件然后执行即可。这些命令就是https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh里面的命令,拷贝出来方便以后使用 #!/bin/sh set -e ZSH=${ZSH:-~/.oh-my-zsh} REPO=${REPO:-ohmyzsh/ohmyzsh} REMOTE=${REMOTE:-https://github.com/${REPO}.git} BRANCH=${BRANCH:-master} CHSH=${CHSH:-yes} RUNZSH=${RUNZSH:-yes} KEEP_ZSHRC=${KEEP_ZSHRC:-no} command_exists() { command -v "$@" >/dev/null 2>&1 } error() { echo ${RED}"Error: $@"${RESET} >&2 } setup_color() { if [ -t 1 ]; then RED=$(printf '\033[31m') GREEN=$(printf '\033[32m') YELLOW=$(printf '\033[33m') BLUE=$(printf '\033[34m') BOLD=$(printf '\033[1m') RESET=$(printf '\033[m') else RED="" GREEN="" YELLOW="" BLUE="" BOLD="" RESET="" fi } setup_ohmyzsh() { umask g-w,o-w echo "${BLUE}Cloning Oh My Zsh...${RESET}" command_exists git || { error "git is not installed" exit 1 } if [ "$OSTYPE" = cygwin ] && git --version | grep -q msysgit; then error "Windows/MSYS Git is not supported on Cygwin" error "Make sure the Cygwin git package is installed and is first on the \$PATH" exit 1 fi git clone -c core.eol=lf -c core.autocrlf=false -c fsck.zeroPaddedFilemode=ignore -c fetch.fsck.zeroPaddedFilemode=ignore -c receive.fsck.zeroPaddedFilemode=ignore --depth=1 --branch "$BRANCH" "$REMOTE" "$ZSH" || { error "git clone of oh-my-zsh repo failed" exit 1 } echo } setup_zshrc() { echo "${BLUE}Looking for an existing zsh config...${RESET}" OLD_ZSHRC=~/.zshrc.pre-oh-my-zsh if [ -f ~/.zshrc ] || [ -h ~/.zshrc ]; then if [ $KEEP_ZSHRC = yes ]; then echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Keeping...${RESET}" return fi if [ -e "$OLD_ZSHRC" ]; then OLD_OLD_ZSHRC="${OLD_ZSHRC}-$(date +%Y-%m-%d_%H-%M-%S)" if [ -e "$OLD_OLD_ZSHRC" ]; then error "$OLD_OLD_ZSHRC exists. Can't back up ${OLD_ZSHRC}" error "re-run the installer again in a couple of seconds" exit 1 fi mv "$OLD_ZSHRC" "${OLD_OLD_ZSHRC}" echo "${YELLOW}Found old ~/.zshrc.pre-oh-my-zsh." "${GREEN}Backing up to ${OLD_OLD_ZSHRC}${RESET}" fi echo "${YELLOW}Found ~/.zshrc.${RESET} ${GREEN}Backing up to ${OLD_ZSHRC}${RESET}" mv ~/.zshrc "$OLD_ZSHRC" fi echo "${GREEN}Using the Oh My Zsh template file and adding it to ~/.zshrc.${RESET}" sed "/^export ZSH=/ c\export ZSH=\"$ZSH\" " "$ZSH/templates/zshrc.zsh-template" > ~/.zshrc-omztemp mv -f ~/.zshrc-omztemp ~/.zshrc echo } setup_shell() { if [ $CHSH = no ]; then return fi if [ "$(basename "$SHELL")" = "zsh" ]; then return fi if ! command_exists chsh; then cat <<-EOF I cannot change your shell automatically because this system does not have chsh. ${BLUE}Please manually change your default shell to zsh${RESET} EOF return fi echo "${BLUE}Time to change your default shell to zsh:${RESET}" printf "${YELLOW}Do you want to change your default shell to zsh? [Y/n]${RESET} " read opt case $opt in y*|Y*|"") echo "Changing the shell..." ;; n*|N*) echo "Shell change skipped."; return ;; *) echo "Invalid choice. Shell change skipped."; return ;; esac case "$PREFIX" in *com.termux*) termux=true; zsh=zsh ;; *) termux=false ;; esac if [ "$termux" != true ]; then if [ -f /etc/shells ]; then shells_file=/etc/shells elif [ -f /usr/share/defaults/etc/shells ]; then shells_file=/usr/share/defaults/etc/shells else error "could not find /etc/shells file. Change your default shell manually." return fi if ! zsh=$(which zsh) || ! grep -qx "$zsh" "$shells_file"; then if ! zsh=$(grep '^/.*/zsh$' "$shells_file" | tail -1) || [ ! -f "$zsh" ]; then error "no zsh binary found or not present in '$shells_file'" error "change your default shell manually." return fi fi fi if [ -n "$SHELL" ]; then echo $SHELL > ~/.shell.pre-oh-my-zsh else grep "^$USER:" /etc/passwd | awk -F: '{print $7}' > ~/.shell.pre-oh-my-zsh fi if ! chsh -s "$zsh"; then error "chsh command unsuccessful. Change your default shell manually." else export SHELL="$zsh" echo "${GREEN}Shell successfully changed to '$zsh'.${RESET}" fi echo } main() { if [ ! -t 0 ]; then RUNZSH=no CHSH=no fi while [ $# -gt 0 ]; do case $1 in --unattended) RUNZSH=no; CHSH=no ;; --skip-chsh) CHSH=no ;; --keep-zshrc) KEEP_ZSHRC=yes ;; esac shift done setup_color if ! command_exists zsh; then echo "${YELLOW}Zsh is not installed.${RESET} Please install zsh first." exit 1 fi if [ -d "$ZSH" ]; then cat <<-EOF ${YELLOW}You already have Oh My Zsh installed.${RESET} You will need to remove '$ZSH' if you want to reinstall. EOF exit 1 fi setup_ohmyzsh setup_zshrc setup_shell printf "$GREEN" cat <<-'EOF' __ __ ____ / /_ ____ ___ __ __ ____ _____/ /_ / __ \/ __ \ / __ `__ \/ / / / /_ / / ___/ __ / /_/ / / / / / / / / / / /_/ / / /_(__ ) / / / \____/_/ /_/ /_/ /_/ /_/\__, / /___/____/_/ /_/ /____/ ....is now installed! Please look over the ~/.zshrc file to select plugins, themes, and options. EOF printf "$RESET" if [ $RUNZSH = no ]; then echo "${YELLOW}Run zsh to try it out.${RESET}" exit fi exec zsh -l } main "$@" 查看当前shell命令echo $SHELL 查看已安装的shell命令cat /etc/shells 切换zsh命令chsh -s /bin/zsh 切换bash命令chsh -s /bin/bash git常用命令总结 oh my zsh 缩写原git命令描述 gst git status 查看当前仓库状态 gaa git add --all 将所有改动添加到暂存区 gcmsg git commit -m 将暂存区提交 gb git branch 查看本地分支 gfo git fetch origin 更新远程分支列表 gba git branch -a 查看所有分支 gbd git branch -d 删除某分支 gbD git branch -D 强制删除某分支 gcb git checkout -b 创建分支并切换 gco git checkout 切换分支 gl git pull 拉代码 gp git push 推代码 gm git merge 合并分支 ggsup git branch --set-upstream-to=origin/$(git_current_branch) 绑定远程同名分支 gpsup git push --set-upstream origin $(git_current_branch) 在远程创建同名分支并关联后将代码推上去 gsta git stash push 将当前改动加入缓存 gstc git stash clear 清空所有缓存 gstl git stash list 查看缓存列表 gstp git stash pop 将最新一条缓存读取出来并删除缓存 grhh git reset --hard 回退到某个commit版本 groh git reset origin/$(git_current_branch) --hard 将远程仓库同名分支回退到某个commit版本 作者:_moses 链接:https://www.jianshu.com/p/8fc095ea4f5e 来源:简书 著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。 |
|
来自: charlie_linux > 《shell》