我在我的 mac(unix) 上使用这个配置来自定义我的 shell。我正在使用 zsh 而不是 bash,并且 zsh 有太多的东西。此.dotfile
配置包含vim, zsh, git, homebrew, nvm, nginx, neovim
相应的主题和配置。随着Oh-my-zsh
我可以定制这么多的主题,但这里zsh
是我的控制壳~/.zshrc
是创建一个符号链接.dotfiles/zsh/zshrc.symlink
文件,我从GitHub的.dotfile捆绑使用它。我已将 oh-my-zsh 版本的 zshrc 文件重命名为 ~/.zshrc.bak。此外,将主题配置添加到文件zsh's
版本~\zshrc
不起作用。如何,我可以更改主题zsh
吗?
来自 ~/.dotfiles 的 zshrc 符号链接
? cat ~/.zshrc
# Ruby Motion android tool
export RUBYMOTION_ANDROID_SDK=/Users/abhimanyuaryan/.rubymotion-android/sdk
export RUBYMOTION_ANDROID_NDK=/Users/abhimanyuaryan/.rubymotion-android/ndk
export DOTFILES=$HOME/.dotfiles
export ZSH=$DOTFILES/zsh
# display how long all tasks over 10 seconds take
export REPORTTIME=10
[[ -e ~/.terminfo ]] && export TERMINFO_DIRS=~/.terminfo:/usr/share/terminfo
# define the code directory
# This is where my code exists and where I want the `c` autocomplete to work from exclusively
if [[ -d ~/code ]]; then
export CODE_DIR=~/code
fi
# source all .zsh files inside of the zsh/ directory
for config ($ZSH/**/*.zsh) source $config
if [[ -a ~/.localrc ]]; then
source ~/.localrc
fi
# initialize autocomplete
autoload -U compinit
compinit
for config ($ZSH/**/*completion.sh) source $config
export EDITOR='nvim'
export PATH=/usr/local/bin:$PATH
# add /usr/local/sbin
if [[ -d /usr/local/sbin ]]; then
export PATH=/usr/local/sbin:$PATH
fi
# adding path directory for custom scripts
export PATH=$DOTFILES/bin:$PATH
# check for custom bin directory and add to path
if [[ -d ~/bin ]]; then
export PATH=~/bin:$PATH
fi
[ -z "$TMUX" ] && export TERM=xterm-256color
# install rbenv
if hash rbenv 2>/dev/null; then
eval "$(rbenv init -)"
fi
if [[ -d ~/.rvm ]]; then
PATH=$HOME/.rvm/bin:$PATH # Add RVM to PATH for scripting
source ~/.rvm/scripts/rvm
fi
# alias git to hub
if hash hub 2>/dev/null; then
eval "$(hub alias -s)"
fi
# source nvm
export NVM_DIR=~/.nvm
if hash brew 2>/dev/null; then
source $(brew --prefix nvm)/nvm.sh
source `brew --prefix`/etc/profile.d/z.sh
fi
# Base16 Shell
# if [ -z "$THEME" ]; then
export THEME="base16-eighties"
# fi
if [ -z "$BACKGROUND" ]; then
export BACKGROUND="dark"
fi
BASE16_SHELL="$DOTFILES/.config/base16-shell/$THEME.$BACKGROUND.sh"
# [[ -s $BASE16_SHELL ]] && source $BASE16_SHELL
source $BASE16_SHELL
Run Code Online (Sandbox Code Playgroud)
oh-my-zsh 版本的 zshrc 文件不起作用。
? cat .zshrc.bak
# Path to your oh-my-zsh installation.
export ZSH=/Users/abhimanyuaryan/.oh-my-zsh
ZSH_THEME="robbyrussell"
plugins=(git)
# User configuration
export PATH="/Users/abhimanyuaryan/bin:/usr/local/bin:/Users/abhimanyuaryan/.rbenv/shims:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin"
# export MANPATH="/usr/local/man:$MANPATH"
source $ZSH/oh-my-zsh.sh
Run Code Online (Sandbox Code Playgroud)
即使我添加ZSH_THEME="agnoster"
了 ~/.zshrc。主题不变。它仍然与尼克提供的相同。
我问他(过去式。他说你的 oh-my-zsh 与我的配置冲突。创建自己的。我不想创建自己的,因为我对所有这些东西都很陌生。一旦我擅长 tmux、vim 和所有这些东西,我将创建自己的。在那之前我只想使用这个 .dotfiles 配置。请帮助我使用此配置自定义我的主题。另外,请帮助我理解 b/w zsh 和 oh-my-zsh 的区别。
小智 9
感谢上面评论中的@John P,因为这确实是他的答案,但对于那些想要一种“动态”更改 zsh 主题而不编辑和重新配置配置的人来说,只需在您的文件中定义此别名即可.zshrc
alias ztheme='(){ export ZSH_THEME="$@" && source $ZSH/oh-my-zsh.sh }'
Run Code Online (Sandbox Code Playgroud)
用法:
ztheme blinks
Run Code Online (Sandbox Code Playgroud)