问题描述
我正在尝试在oh-my-zsh / custom文件夹中创建一个自定义文件,以便更好地组织别名。问题是,每当我重新启动外壳程序时(将其通过命令.oh-my-zsh/custom/aliases.zsh
执行),当我将其添加到source ~/.zshrc
文件中时,实际上每次都将别名打印在顶部。如何禁止这种情况发生?
.zshrc文件是否有问题?我把它整理得更好一些,但也许我在某个地方破坏了配置。您能看到我的.zshrc有什么问题吗?如果没有,您认为问题可能是什么?
# ------------| .ZSHRC | ----------------
#----------------------------------------
# ------ Export Paths
export PATH=$HOME/bin:/usr/local/bin:$PATH
export ZSH="/Users/cnode/.oh-my-zsh"
export PATH=$PATH:/opt/WebDriver/bin >> ~/.profile
export PATH=$PATH:/Users/cnode/Library/Application\ Support/Sublime\ Text\ 3/Packages/User/Deviot/penv/bin
# test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
export LANG=en_US.UTF-8
# ------ ZSH Config
ZSH_THEME="af-magic"
#ZSH_THEME="robbyrussell"
# ZSH_THEME="avit"
plugins=(git iterm2 z)
#-- For zsh-z
autoload -U compinit && compinit
# zstyle ':completion:*' menu select
# --------Preferred Editor
if [[ -n $SSH_CONNECTION ]]; then
export EDITOR='subl -w'
else
export EDITOR='vim'
fi
source $ZSH/oh-my-zsh.sh
source ~/.iterm2_shell_integration.zsh
# ------- Dir browsing
d='dirs -v | head -10'
1='cd -'
2='cd -2'
3='cd -3'
4='cd -4'
5='cd -5'
6='cd -6'
7='cd -7'
8='cd -8'
9='cd -9'
# 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 edit="subl ~/.zshrc"
alias editzsh="subl ~/.zshrc"
alias editomzsh="subl ~/.oh-my-zsh"
alias rst="source ~/.zshrc"
alias appid="appID"
alias cheat="vim ~/cube/cmdDoc/cheatsheet.txt"
alias cheatsheet="subl ~/cube/cmdDoc/cheatsheet.txt"
alias putbinhere='putbin'
alias connex='ssh jrapa86@107.180.93.44'
alias npmr='npm run'
alias npmi='npm install --save '
alias goto-hexo='cd /Users/cnode/cube/jsEnv/hexo/blog'
alias go-hexo='goto-hexo'
function hexotheme(){
tmpDir='/Users/cnode/tmp/hexotheme.tmp'
themeDir='/Users/cnode/cube/jsEnv/hexo/blog/themes'
$(pwd)>>/Users/cnode/tmp/hexotheme.tmp
cd $themeDir
git clone `pbpaste`
cd ~
}
function paste(){
ps aux | pbcopy
echo `pbpaste`
}
appID(){
osascript -e 'id of app "'$1'"'
}
add_function(){
newfxn=$(
echo $1'(){'
echo "${2}"
echo '}'
)
echo $newfxn>>~/.zshrc
rst
}
run(){
sh $1'.sh'
}
makeExec(){
FILE=$1
chmod u+x $FILE
echo $FILE' is Now executable'
}
test -e "${HOME}/.iterm2_shell_integration.zsh" && source "${HOME}/.iterm2_shell_integration.zsh"
export EDITOR='subl -w'
# Added Custom Functions from the command line
#------------------------------------------
解决方法
不要将别名放在.sh文件源中,例如compile_italic('*italic*')
>>>'<i>italic</i>'
compile_italic('this is *italic*!')
>>> 'this is <i>italic</i>!'
compile_italic_star('*italic*,and *italic*!')
>>> '<i>italic</i>,and <i>italic</i>!'
compile_italic_star('not *italic')
>>> not *italic'
OMZ也是一个集群,避免使用它,您可以实现相同/相似。