Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
2014.2的zsh问题(自己解决了)
Experiences and Insight
969
views ·
8
replies ·
To
floor
Go
ztps
deepin
2014-11-30 10:43
Author
临睡之前,在发一贴。
内测的2014.2的深度终端默认zsh,这货竟然记不住历史命令。
zsh这货怎么样记不住呢,相比bash可以在关闭终端重新打开时,用方向键,上,调出历史命令。
它始终无动于衷。
找bug好累,睡了。一会就3点了。
Reply
Like 0
Favorite
View the author
All Replies
wayer
deepin
2014-11-30 18:10
#1
没遇到这个问题
Reply
Like 0
View the author
ksliubaoming
deepin
2014-11-30 18:23
#2
麻烦你测试一下安装一下 inkscape ,帮我看看工具图标能正常显示吗?
以下是 deepin 主题图标不正常显示截图
DeepinScreenshot20141130103118.png
以下是 LMint 主题图标正常显示截图
DeepinScreenshot20141130102909.png
在此先谢谢!!!
Reply
Like 0
View the author
hgfrzh
deepin
2014-11-30 19:03
#3
我的可以
Reply
Like 0
View the author
ztps
deepin
2014-11-30 19:50
#4
好吧。
我现在需要一份 zshrc 的模板
Reply
Like 0
View the author
ztps
deepin
2014-11-30 20:21
#5
github上找了一份,先用着
# -*- shell-script -*-
#
# optional:
# autojump
# git-flow-avh
#
#[[[ base
# 设置默认编码
export LANG=en_US.UTF-8
export LC_ALL=$LANG
# 设置默认编辑器,打命令的时候试试 C-x C-e
export EDITOR=vim
# 允许在交互模式中使用注释 例如:
# cmd... # 这是注释
setopt INTERACTIVE_COMMENTS
# 启用自动 cd,输入目录名回车进入目录
# 稍微有点混乱,不如 cd 补全实用
# setopt AUTO_CD
# 不要蜂鸣警报 beep
setopt NO_BEEP
# 禁用 core dumps
limit coredumpsize 0
# 以下字符视为单词的一部分
WORDCHARS='*?_-[]~=&;!#$%^(){}<>'
# 行编辑高亮模式
# Ctrl+@ 设置标记,标记和光标点之间为 region
zle_highlight=(region:bg=magenta # 选中区域
special:bold # 特殊字符
isearch:underline)#搜索时使用的关键字
source ~/dotfiles/zshfiles/theme.zsh
# custom files
if [ -d $HOME/.zshcustoms ]; then
for file in `ls -1 $HOME/.zshcustoms`; do
source $HOME/.zshcustoms/$file
done
fi
#]]]
# shundle [[[
if [ ! -d ~/.shundle/bundle/shundle ]; then
git clone --depth=1 https://github.com/chilicuil/shundle ~/.shundle/bundle/shundle
fi
export SHUNDLE_RC=~/dotfiles/zshfiles/shundle.zsh
source ~/.shundle/bundle/shundle/shundle
# ]]]
# directories [[[
setopt auto_name_dirs
setopt auto_pushd
setopt pushd_ignore_dups
setopt pushdminus
alias d='dirs -v | head -10'
alias 1='cd -'
alias 2='cd -2'
alias 3='cd -3'
alias 4='cd -4'
alias 5='cd -5'
alias 6='cd -6'
alias 7='cd -7'
alias 8='cd -8'
alias 9='cd -9'
# ]]]
#[[[ alias
# 计算器
function qbc() {
echo "$@" | bc
}
# 查询维基百科
function wiki() {
dig +short txt ${1}.wp.dg.cx
}
# 查询 Gmail 的未读邮件,记得在命令前加空格
function gmail() {
curl -u ${1}@gmail.com:${2} --silent "https://mail.google.com/mail/feed/atom" |
tr -d '\n' |
awk -F '' '{for (i=2; i<=NF; i++) {print $i}}' |
perl -pe 's/^(.*)<\/title>.*<name>(.*)<\/name>.*$/$2 - $1/'<li>}<li><li># 查询 commandlinefu.com<li>function cmdfu() {<li> if [ "$1" = "byVote" ] ; then<li> local query="browse/sort-by-votes"<li> else<li> local query="matching/$@/$(echo -n $@ | openssl base64)"<li> fi<li> curl "http://www.commandlinefu.com/commands/$query/plaintext";<li>}<li><li># 列出 Git 管理的目录下所有发生过改动的文件,使用方法:<li># chdfiles 2 # 文件下标(从 1 开始,默认为 1)<li># chdfiles a # 列出所有文件<li>function chdfiles() {<li> files=$(git status -s | cut -c 4-)<li> [ "$1" = "" ] && 1="1"<li><li> if [ "$1" = "a" ] ; then<li> echo $files<li> else<li> echo $files | xargs | cut -d ' ' -f $1<li> fi<li>}<li><li>function _ssh-copy-id() {<li> cat ~/.ssh/id_rsa.pub | ssh $1 "[ -d ~/.ssh ] || mkdir ~/.ssh; cat >> ~/.ssh/authorized_keys"<li>}<li># http://stackoverflow.com/questions/592620/check-if-a-program-exists-from-a-bash-script<li>hash ssh-copy-id 2>/dev/null || { alias ssh-copy-id='_ssh-copy-id' }<li><li>function timeconv { date -d @$1 +"%Y-%m-%d %T" }<li><li>function cl() {<li> cd $1<li> ls<li>}<li>alias ls='ls --color=auto'<li>alias lsa='ls -lah'<li>alias l='ls -la'<li>alias ll='ls -l'<li>alias la='ls -lA'<li>alias sl=ls # often screw this up<li><li>alias cp='cp -i'<li>alias mv='mv -i'<li>alias rm='rm -i'<li>alias grep='grep --color=auto'<li>alias swapcaps='setxkbmap -option ctrl:swapcaps'<li>alias startx='startx > ~/.log/x.log &'<li>alias zhcon='zhcon --utf8'<li>alias closeLCD='xset dpms force off'<li><li># [Esc][h] man 当前命令时,显示简短说明<li>alias run-help >&/dev/null && unalias run-help<li>autoload run-help<li><li># 历史命令 top10<li>alias top10='print -l ${(o)history%% *} | uniq -c | sort -nr | head -n 10'<li><li># Print all 256 colors for testing TERM or for a quick reference<li>alias color256='( x=`tput op` y=`printf %$((${COLUMNS}-6))s`;for i in {0..256};do o=00$i;echo -e ${o:${#o}-3:3} `tput setaf $i;tput setab $i`${y// /=}$x;done; )'<li><li># 路径别名<li># 进入相应的路径时只要 cd ~xxx<li>hash -d WWW="/home/lighttpd/html"<li>hash -d ARCH="/mnt/arch"<li>hash -d PKG="/var/cache/pacman/pkg"<li>hash -d E="/etc/env.d"<li>hash -d C="/etc/conf.d"<li>hash -d I="/etc/rc.d"<li>hash -d X="/etc/X11"<li>#]]]<li>#[[[ key binding<li># Emacs 风格 键绑定<li>bindkey -e<li><li># 空行(光标在行首)补全 cd<li>cd-complete() {<li> if [[ ! -n $BUFFER ]] ; then<li> BUFFER="cd "<li> zle end-of-line<li> fi<li> zle expand-or-complete<li>}<li>zle -N cd-complete<li>bindkey "\t" cd-complete<li><li># 在命令前插入 sudo<li>sudo-command-line() {<li> [[ -z $BUFFER ]] && zle up-history<li> [[ $BUFFER != sudo\ * ]] && BUFFER="sudo $BUFFER"<li> #光标移动到行末<li> zle end-of-line<li>}<li>zle -N sudo-command-line<li># 定义快捷键为: [Esc] [Esc]<li>bindkey "\e\e" sudo-command-line<li><li>autoload edit-command-line<li>zle -N edit-command-line<li>bindkey '^X^E' edit-command-line<li><li># 设置 [DEL]键 为向后删除<li>bindkey "\e[3~" delete-char<li>#]]]<li>#[[[ history<li><li># 历史纪录条目数量<li>export HISTSIZE=10000<li># 注销后保存的历史纪录条目数量<li>export SAVEHIST=10000<li><li># 定义函数,替换原来的 cd<li>cd() {<li> builtin cd "$@" # 执行原来的 cd 命令<li> fc -W # 写历史纪录文件,默认参数为 $HISTFILE 。初始值为 #2 处的定义;执行了 cd 命令后为 #1 处的定义<li> # 实际上,你不可能在每个目录下都执行个把命令,很多目录你没有去过,只要为你去过的目录建立历史纪录就可以了<li> local HISTDIR="$HOME/.zsh_history$PWD" # 定义历史纪录目录。每次 cd 后,$PWD 对应与工作目录层级相同的目录<li> if [ ! -d "$HISTDIR" ] ; then # 如果不存在这个目录,则建立一个<li> mkdir -p "$HISTDIR"<li> fi<li> export HISTFILE="$HISTDIR/zhistory" #1 定义历史纪录文件<li> touch $HISTFILE # 先 touch 一下,如果不存在的话就会新建一个<li> # 清空原来的历史纪录<li> local ohistsize=$HISTSIZE # 设定一个变量临时存储原历史纪录大小<li> HISTSIZE=0 # 通过禁用历史纪录清空<li> HISTSIZE=$ohistsize # 重新设定历史纪录大小<li> fc -R # 读历史纪录文件,默认参数为 $HISTFILE 。也就是 #1 处的定义<li>}<li># 启动 zsh 的时候,并没有执行 cd 命令,因此 $HOME 目录对应的历史纪录目录可能不存在,先建立它<li>mkdir -p $HOME/.zsh_history$PWD<li>#2 同样,启动 zsh 的时候, 还没有定义 $HOME 目录对应的 $HISTFILE ,所以先定义它<li>export HISTFILE="$HOME/.zsh_history$PWD/zhistory"<li><li># 使用 setopt EXTENDED_HISTORY 选项,为命令添加时间戳<li># 这非常重要,汇总到一起的历史纪录比较混乱,时间戳是重新排序的依据<li>setopt EXTENDED_HISTORY<li><li># 定义 allhistory ,将所有的历史纪录汇总到一起<li>function allhistory { cat $(find $HOME/.zsh_history -name zhistory) }<li># 针对历史纪录的格式进行转换<li>function convhistory {<li> sort $1 | # 排序<li> uniq | # 合并相同行。<li> # 由于时间戳精确到秒,所以几乎不可能有相同的纪录<li> # 出现相同的纪录是因为 zsh 的处理方式,每次 cd 会在两个纪录文件中产生相同的 cd 命令<li> sed 's/^:\([ 0-9]*\):[0-9]*;\(.*\)/\1::::::\2/' | # 去掉历史纪录中不需要的字段。添加自定义的分隔符,方便下一步处理<li> awk -F"::::::" '{ $1=strftime("%Y-%m-%d %T",$1) "|"; print }' # 将 UNIX 时间戳转换成可以看懂的格式<li>}<li><li># 使用 histall 命令查看全部历史纪录<li>function histall { convhistory =(allhistory) | sed '/^.\{20\} *cd/i\\' } # 在每个 cd 命令前添加空行,判断工作目录比较容易<li># 可能会有一点不准确。因为启动和退出时不执行 cd 命令,没有相应的纪录。尤其是同时运行多个 zsh 的时候<li># 使用 hist 查看当前目录历史纪录<li>function hist { convhistory $HISTFILE }<li>#]]]<li>#[[[ auto complete<li><li>setopt AUTO_LIST<li>setopt AUTO_MENU<li># 开启此选项,补全时会直接选中菜单项<li>setopt MENU_COMPLETE<li><li>autoload -U compinit && compinit<li><li># 自动补全缓存<li>#zstyle ':completion::complete:*' use-cache on<li>#zstyle ':completion::complete:*' cache-path .zcache<li>#zstyle ':completion:*:cd:*' ignore-parents parent pwd<li><li># 自动补全选项<li>zstyle ':completion:*:match:*' original only<li>zstyle ':completion::prefix-1:*' completer _complete<li>zstyle ':completion:predict:*' completer _complete<li>zstyle ':completion:incremental:*' completer _complete _correct<li>zstyle ':completion:*' completer _complete _prefix _correct _prefix _match _approximate<li><li># 路径补全<li>zstyle ':completion:*' expand 'yes'<li>zstyle ':completion:*' squeeze-shlashes 'yes'<li>zstyle ':completion::complete:*' '\\'<li><li>zstyle ':completion:*' menu select<li>zstyle ':completion:*:*:default' force-list always<li><li># 彩色补全菜单<li>eval $(dircolors -b)<li>export ZLSCOLORS="${LS_COLORS}"<li>zmodload zsh/complist<li>zstyle ':completion:*' list-colors ${(s.:.)LS_COLORS}<li>zstyle ':completion:*:*:kill:*:processes' list-colors '=(#b) #([0-9]#)*=0=01;31'<li><li># 错误校正<li>zstyle ':completion:*' completer _complete _match _approximate<li>zstyle ':completion:*:match:*' original only<li>zstyle ':completion:*:approximate:*' max-errors 1 numeric<li><li># kill 命令补全<li>compdef pkill=kill<li>compdef pkill=killall<li>zstyle ':completion:*:*:kill:*' menu yes select<li>zstyle ':completion:*:*:*:*:processes' force-list always<li>zstyle ':completion:*:processes' command 'ps -au$USER'<li><li># 补全类型提示分组<li>zstyle ':completion:*:matches' group 'yes'<li>zstyle ':completion:*' group-name ''<li>zstyle ':completion:*:options' description 'yes'<li>zstyle ':completion:*:options' auto-description '%d'<li>zstyle ':completion:*:descriptions' format $'\e[01;33m -- %d --\e[0m'<li>zstyle ':completion:*:messages' format $'\e[01;35m -- %d --\e[0m'<li>zstyle ':completion:*:warnings' format $'\e[01;31m -- No Matches Found --\e[0m'<li>#]]]<li># vim:fileencoding=utf-8 filetype=zsh expandtab shiftwidth=2</ol></div><em 0nclick="copycode($('code_NxY'));">Copy the Code</em></div>
Reply
Like 0
View the author
MattD
deepin
2014-11-30 21:06
#6
oh-my-zsh路过
Reply
Like 0
View the author
ztps
deepin
2014-11-30 21:44
#7
oh-my-zsh路过
现在用的就是oh-my-zsh,替换了默认的zsh,感觉不错
:
Reply
Like 0
View the author
呆了个呆
deepin
2014-12-01 09:11
#8
应该可以切换成 bash 吧
Reply
Like 0
View the author
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
Error configurar cara autenticacion biometrica
Hız
add screenshot to message sent early
HP Pavilion extremly slow
HP Printer smart tank 5105 not support
Popular Events
More
内测的2014.2的深度终端默认zsh,这货竟然记不住历史命令。
zsh这货怎么样记不住呢,相比bash可以在关闭终端重新打开时,用方向键,上,调出历史命令。
它始终无动于衷。
找bug好累,睡了。一会就3点了。