zshを使用してテーマを変更する方法

zshを使用してテーマを変更する方法

使っていますこの構成私のMac(unix)で私のシェルをカスタマイズします。私はbashの代わりにzshを使用していますが、zshはテーブルにあまりにも多くをインポートします。構成にはそれぞれのテーマと構成が.dotfile含まれています。vim, zsh, git, homebrew, nvm, nginx, neovimカスタマイズOh-my-zshできるテーマが多すぎますが、これはzsh私のシェルを制御し、~/.zshrcGithubの.dotfileパッケージで使用されるファイルを使用して生成されたシンボリックリンクです。.dotfiles/zsh/zshrc.symlinkzshrc ファイルの oh-my-zsh バージョン名を ~/.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

zshrc ファイルの oh-my-zsh バージョンが機能しません。

❯ 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

ZSH_THEME="agnoster"~/.zshrcに追加しても。テーマは変わりません。それでもNickが提供するものと同じです。

私は彼に尋ねました(過去の時制。彼はあなたのoh-my-zshが私の構成と衝突すると言いました。自分で作ってください。私はこれに慣れていないので、私を作りたくありません。tmuxに慣れたら、vimを使用して、このすべてを自分だけのものにします。

ベストアンサー1

上記の説明で@John Pに感謝します。これは実際に彼の答えですが、構成を編集して再構成せずにzshテーマを「動的に」変更する方法を望む人は、ファイルに定義するだけです。.zshrc

alias ztheme='(){ export ZSH_THEME="$@" && source $ZSH/oh-my-zsh.sh }'

使用法:

ztheme blinks

おすすめ記事