赞
踩
首先,查看linux系统自带哪些shell
cat /etc/shells
1.安装zsh:
sudo apt-get install zsh
编译
没有root权限的用户,也可以通过源码安装(安装到自己的目录)
在官网下载源码包:https://sourceforge.net/projects/zsh/
tar -zxvf zsh-5.7.1.tar.xz
cd zsh-5.7.1
mkdir install
./configure --prefix=/public/home/xxxx/install/zsh-5.7.1/install
make && make install
将默认shell切换为zsh
在/.bashrc 最后面写入,每次默认启动zsh
exec /public/home/jiahao/install/zsh-5.7.1/install/bin/zsh
alias zsh=/public/home/jiahao/install/zsh-5.7.1/install/bin/zsh
2.确认是否安装成功
zsh --version
3.切换当前默认的shell
chsh -s /bin/zsh
有的平台上面的命令有问题,可以试一下下面的这一个
command -v zsh | sudo tee -a /etc/shells
/usr/bin/zsh
mkdir .oh-my-zsh
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
以后所有修改配置文件,都是在.zshrc文件里面修改即可。
最后,需要source ~/.zshrc将配置生效。以下修改了.zshrc文件之后,都执行一下这个命令
通过如下命令可以查看可用的Theme:
ls ~/.oh-my-zsh/themes
如何修改zsh主题呢?
编辑~/.zshrc文件,将ZSH_THEME=“candy”,即将主题修改为candy。我采用的ys。
安装对应的插件
sudo apt-get install extract
在~/.zshrc中找到plugins关键字,就可以自定义启用的插件了,系统默认加载git。
打开文件~/.zshrc,其中有如下行:
plugins=(git)
将需要的插件按空格分开,放于此处即可。我的配置如下(这是4个插件)
plugins=(git extract z sublime)
解压文件用的,所有的压缩文件,都可以直接x filename,不用记忆参数
当然,如果你想要用tar命令,可以使用tar -加tab键,zsh会列出参数的含义
强大的目录自动跳转命令,会记忆你曾经进入过的目录,用模糊匹配快速进入你想要的目录
z -stat:可以查看历史路径库 历史访问记录放在 .z
文件里
命令内容可以参考cat ~/.oh-my-zsh/plugins/git/git.plugin.zsh。
zsh-autosuggestion 插件
手动下载解压,注意修改文件夹的名字放到
/home/jiahao/.oh-my-zsh/custom/plugins/ 目录下 不要zsh-autosuggestion目录套zsh-autosuggestion目录
source ~/.zshrc
clone项目到文件夹下 (默认为 ~/.oh-my-zsh/custom/plugins)
cd ~/.oh-my-zsh/custom/plugins
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git
autoload: command not found
bash: /home/hyh/.oh-my-zsh/oh-my-zsh.sh: line 34: syntax error near unexpected token `('
bash: /home/hyh/.oh-my-zsh/oh-my-zsh.sh: line 34: `for config_file ($ZSH/lib/*.zsh); do'
解决方法:
在终端上直接输入 zsh
一切正常。
但是 不会让我每次打开一个终端,都要我输入一次zsh吧?
我直接把 zsh 追加到HOME/.bashrc
最后面
这样每次打开终端就会帮我自动输入一次zsh命令
但是这种方式慎用,可能会导致scp的时候卡住,别的机器不能往你这台机器上scp文件
rm -rf .zcompdump
rm -rf .zcompdump-ubuntu-5.1.1
.zshrc
文件配置在我的zshrc文件中使用alias来简化一些常用的命令,来提升效率,如:
alias ff="find . -name"
alias gg='grep -rn'
简化经常使用的查找文件以及查找某些字符
alias yoc='cd /home/xx/xx'
简化自己经常访问的开发目录
alias mkcscopefile='find `pwd` -name "*.[ch]" -o -name "*.cpp" > cscope.files'
alias mktag='ctags -R;cscope -bR'
简化cscope命令,来建立代码中函数以及变量等的链接
# If you come from bash you might have to change your $PATH. # export PATH=$HOME/bin:/usr/local/bin:$PATH # Path to your oh-my-zsh installation. export ZSH=$HOME/.oh-my-zsh # Set name of the theme to load --- if set to "random", it will # load a random theme each time oh-my-zsh is loaded, in which case, # to know which specific one was loaded, run: echo $RANDOM_THEME # See https://github.com/ohmyzsh/ohmyzsh/wiki/Themes ZSH_THEME="ys" # Set list of themes to pick from when loading at random # Setting this variable when ZSH_THEME=random will cause zsh to load # a theme from this variable instead of looking in ~/.oh-my-zsh/themes/ # If set to an empty array, this variable will have no effect. # ZSH_THEME_RANDOM_CANDIDATES=( "robbyrussell" "agnoster" ) # Uncomment the following line to use case-sensitive completion. CASE_SENSITIVE="true" setopt no_nomatch CSCOPE_DB=/home/jiahao/hongmeng//hm-verif-kernel/cscope.out export CSCOPE_DB # Uncomment the following line to use hyphen-insensitive completion. # Case-sensitive completion must be off. _ and - will be interchangeable. # HYPHEN_INSENSITIVE="true" # Uncomment the following line to disable bi-weekly auto-update checks. # DISABLE_AUTO_UPDATE="true" # Uncomment the following line to automatically update without prompting. # DISABLE_UPDATE_PROMPT="true" # Uncomment the following line to change how often to auto-update (in days). # export UPDATE_ZSH_DAYS=13 # Uncomment the following line if pasting URLs and other text is messed up. # DISABLE_MAGIC_FUNCTIONS=true # Uncomment the following line to disable colors in ls. # DISABLE_LS_COLORS="true" # Uncomment the following line to disable auto-setting terminal title. # DISABLE_AUTO_TITLE="true" # Uncomment the following line to enable command auto-correction. # ENABLE_CORRECTION="true" # Uncomment the following line to display red dots whilst waiting for completion. # COMPLETION_WAITING_DOTS="true" # Uncomment the following line if you want to disable marking untracked files # under VCS as dirty. This makes repository status check for large repositories # much, much faster. # DISABLE_UNTRACKED_FILES_DIRTY="true" # Uncomment the following line if you want to change the command execution time # stamp shown in the history command output. # You can set one of the optional three formats: # "mm/dd/yyyy"|"dd.mm.yyyy"|"yyyy-mm-dd" # or set a custom format using the strftime function format specifications, # see 'man strftime' for details. # HIST_STAMPS="mm/dd/yyyy" # Would you like to use another custom folder than $ZSH/custom? # ZSH_CUSTOM=/path/to/new-custom-folder # Which plugins would you like to load? # Standard plugins can be found in ~/.oh-my-zsh/plugins/* # Custom plugins may be added to ~/.oh-my-zsh/custom/plugins/ # Example format: plugins=(rails git textmate ruby lighthouse) # Add wisely, as too many plugins slow down shell startup. plugins=( gitfast z extract sublime zsh-syntax-highlighting ) source $ZSH/oh-my-zsh.sh source ~/.profile # User configuration # export MANPATH="/usr/local/man:$MANPATH" # You may need to manually set your language environment # export LANG=en_US.UTF-8 # Preferred editor for local and remote sessions # if [[ -n $SSH_CONNECTION ]]; then # export EDITOR='vim' # else # export EDITOR='mvim' # fi # Compilation flags # export ARCHFLAGS="-arch x86_64" # Set personal aliases, overriding those provided by oh-my-zsh libs, # plugins, and themes. Aliases can be placed here, though oh-my-zsh # users are encouraged to define aliases within the ZSH_CUSTOM folder. # For a full list of active aliases, run `alias`. # # Example aliases # alias zshconfig="mate ~/.zshrc" # alias ohmyzsh="mate ~/.oh-my-zsh" # This speeds up pasting w/ autosuggest # https://github.com/zsh-users/zsh-autosuggestions/issues/238 pasteinit() { OLD_SELF_INSERT=${${(s.:.)widgets[self-insert]}[2,3]} zle -N self-insert url-quote-magic # I wonder if you'd need `.url-quote-magic`? } pastefinish() { zle -N self-insert $OLD_SELF_INSERT } zstyle :bracketed-paste-magic paste-init pasteinit zstyle :bracketed-paste-magic paste-finish pastefinish alias ff="find . -name" alias gg='grep -rn' alias yoc='cd /home/xx/xx' alias jj='z' alias mkcscopefile='find `pwd` -name "*.[ch]" -o -name "*.cpp" -o -name "*.hpp" > cscope.files' alias mktag='ctags -R;cscope -bR' export PATH=$HOME/install/qemu:$PATH export PATH=$HOME/install/SDK/sysroots/x86_64-eulersdk-linux/usr/bin:$PATH export PATH=$HOME/install/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin:$PATH [[ -s ~/.autojump/etc/profile.d/autojump.sh ]] && . ~/.autojump/etc/profile.d/autojump.sh
有的时候会感觉安装zsh以后,使用git 命令在用tab补全的时候很慢,可以加一下gitfast
这个插件试一下
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。