bash环境下自动安装并初始化oh-my-zsh & autojump zsh

和Mac系统默认的shell 都是bash,但是真正强大的shell应属于zsh,而且完全监控bash,是shell中的终极杀手,有很多bash所没有的功能,但是zsh的初期配置太过繁琐,流行率一直不高,直到有个叫Robby Russell的家伙在上开发了oh-my-zsh项目,使大家使用zsh的便捷性大大提高。

由于在公司的电脑是,就折腾了下cygwin,并且安装了zsh,这样做起维护方便很多了,而且我把autojump项目也集成一起,最后写了一个自动安装的脚本,可以自动从当前bash环境下安装Oh-my-zsh, autojump并初始化zsh。目前只支持, Debian。

我在网上收集这这套zsh profile支持的插件有(git autojump history history-substring-search systemadmin systemd), 具体使用可以查看插件~.oh-my-zsh/plugins/。

autojump使用方法请看autojump的官方文档。https://github.com/wting/autojump
history-substring-search 搜索历史明亮非常强大,强大到令你乍舌。
systemadmin集成了很多SA常用的命令。
systemd 对于centos7以后的systemctl精简比较智能。

#!/bin/bash
#Author:Shanker
#set -x
#set -u
clearhacker
 
echo “”
echo “#############################################################”
echo “# Automatically to  Install oh-my-zsh and initialize it    #”
echo “# Intro: https://github.com/sangrealest/shanker            #”

echo “#############################################################”
echo “”
#if [ `id -u` -ne 0 ]
#then
#    echo “Need root to run is, try with sudo”
#    exit 1
#fi
function checkOs(){
    if [ -f /etc/-release ]
    then
        OS=”
    elif [ ! -z “`cat /etc/issue | grep -i bian`” ]
    then
        OS=”Debian”
    elif [ ! -z “`cat /etc/issue | grep -i ubuntu`” ]
    then
        OS=”Ubuntu”
    else
        echo “Not supported OS”
        exit 1
    fi
}
function installSoftware(){
if [ “$OS” == ‘' ]
then
    sudo yum -y install zsh git
else
    sudo apt-get -y install zsh git
fi
zshPath=”`which zsh`”
}
function downloadFile(){
    cd ~
    git clone https://github.com/robbyrussell/oh-my-zsh.git ~/.oh-my-zsh
    git clone https://github.com/joelthelion/autojump.git
    git clone https://github.com/sangrealest/initzsh
}
function installAutojump(){
    cd ~/autojump
    ./install.py

[[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && source ~/.autojump/etc/profile.d/autojump.sh
autoload -U compinit && compinit -u
EOF
}
function configZsh(){
    if [ -f “.zsh_history” ]
    then
        mv .zsh_history{.,backup}
    fi
    sudo chsh -s “$zshPath”
    cp ~/initzsh/zshrc ~/.zshrc
}
function main(){
checkOs
installSoftware
downloadFile
configZsh
installAutojump
}
main

如果是cygwin使用zsh,只需要在你的.bashrc里面加上一行 /bin/zsh即可。
效果如图:

bash环境下自动安装并初始化oh-my-zsh & autojump zsh

转载自:https://www.linuxidc.com/Linux/2016-01/127841.htm

声明: 除非转自他站(如有侵权,请联系处理)外,本文采用 BY-NC-SA 协议进行授权 | 智乐兔
转载请注明:转自《bash环境下自动安装并初始化oh-my-zsh & autojump zsh
本文地址:https://www.zhiletu.com/archives-5779.html
关注公众号:智乐兔

赞赏

wechat pay微信赞赏alipay pay支付宝赞赏

上一篇
下一篇

相关文章

在线留言

你必须 登录后 才能留言!

在线客服
在线客服 X

售前: 点击这里给我发消息
售后: 点击这里给我发消息

智乐兔官微