修改zsh time命令的结果

~/.zshrc添加如下内容

TIMEFMT='%J   %U  user %S system %P cpu %*E total'$'\n'\
'avg shared (code):         %X KB'$'\n'\
'avg unshared (data/stack): %D KB'$'\n'\
'total (sum):               %K KB'$'\n'\
'max memory:                %M MB'$'\n'\
'page faults from disk:     %F'$'\n'\
'other page faults:         %R'

修改命令的提示

PROMPT="%{$fg_bold[green]%}%n%{$fg[blue]%}@%{$fg_bold[yellow]%}%m %(?:%{$fg_bold[green]%}➜ :%{$fg_bold[red]%}➜ )"
PROMPT+='%{$fg[cyan]%}%c%{$reset_color%} $(git_prompt_info)
%# '

ZSH_THEME_GIT_PROMPT_PREFIX="%{$fg_bold[blue]%}git:(%{$fg[red]%}"
ZSH_THEME_GIT_PROMPT_SUFFIX="%{$reset_color%} "
ZSH_THEME_GIT_PROMPT_DIRTY="%{$fg[blue]%}) %{$fg[yellow]%}✗"
ZSH_THEME_GIT_PROMPT_CLEAN="%{$fg[blue]%})"

PROMPT的语法

https://zsh.sourceforge.io/Doc/Release/Prompt-Expansion.html

添加改变标题功能

DISABLE_AUTO_TITLE="true"

function tabtitle() {
  echo -en "\e]2;$@\a"
}

在shell中通过tabtitle my title即可将当前shell的标题修改为my title.

没有sudo权限设置zsh为默认的shell

修改.bashrc,添加如下内容到文件尾部。

zsh_path=/usr
echo $zsh_path "zshpath"
export PATH=$zsh_path/bin:$PATH

[ -f $zsh_path/bin/zsh ] && exec $zsh_path/bin/zsh -l

登录错误

在一些比较奇怪的环境下登录时,可能会出现这样的错误compinit: function definition file not found,可以先通过locate compinit确认这个函数是在zsh目录下的。比如

/usr/share/zsh/5.5.1/functions/bashcompinit
/usr/share/zsh/5.5.1/functions/compinit

由于没有sudo权限,我是通过修改.bashrc来设置zsh为默认shell的。因此,需要将如上的路径添加到~/.bashrc

export FPATH=/usr/share/zsh/5.5.1/functions:$FPATH

添加python脚本命令的提示

pip install argcomplete activate-global-python-argcomplete

others

alias acp="xargs echo -n | xclip -sel clip"
alias xcp="xargs echo -n | xclip -sel clip"
alias makea="make clean && make -j"
alias a2="aria2c"

Reference

https://unix.stackexchange.com/questions/136423/making-zsh-default-shell-without-root-access https://kislyuk.github.io/argcomplete/


文章版权归 FindHao 所有丨本站默认采用CC-BY-NC-SA 4.0协议进行授权|
转载必须包含本声明,并以超链接形式注明作者 FindHao 和本文原始地址:
https://findhao.net/easycoding/2593.html

Comments