Ability to store your own prompts in ~/.zsh.prompts [Close #152]

We no longer pollute yadr or prezto directories with custom code!
This commit is contained in:
Yan Pritzker 2012-09-26 11:05:28 -07:00
parent d8e5043c40
commit fa357bbd35
7 changed files with 32 additions and 12 deletions

View File

@ -152,10 +152,7 @@ After a lifetime of bash, I am now using ZSH as my default shell because of its
and autocomplete features (the spelling fixer autocomplete is worth the money alone).
Migrating from bash to zsh is essentially pain free. The zshrc provided here
restores the only feature that I felt was 'broken' which is the Ctrl-R reverse history search.
While I am not going to support bash out of the box here, YADR _should_ work with bash if
you just source the _aliases_ file. However, you soul will sing if you install zsh. I promise.
restores a few features that I felt was 'broken' including Ctrl-R reverse history search.
Lots of things I do every day are done with two or three character
mnemonic aliases. Please feel free to edit them:
@ -163,17 +160,31 @@ mnemonic aliases. Please feel free to edit them:
ae # alias edit
ar # alias reload
### [ZSH Customizations & Prezto](https://github.com/sorin-ionescu/prezto)
### [Prezto](https://github.com/sorin-ionescu/prezto)
For a more complete Zsh experience we use **[Prezto](http://github.com/sorin-ionescu/prezto)**.
Prezto is included as a submodule.
### Adding your own ZSH theme
If you want to add your own zsh theme, you can place it into ~/.zsh.prompts and it will automatically be picked up by the prompt loader.
Make sure you follow the naming convention of `prompt_[name]_setup`
```
touch ~/.zsh.prompts/prompt_mytheme_setup
```
Check out ~/.yadr/zsh/prezto-themes/prompt_skwp_setup for an example of how to write a prompt.
See also the [Prezto](https://github.com/sorin-ionescu/prezto) project for more info on themes.
### Customizing ZSH & Picking a theme
If you want to customize your zsh experience, yadr provides two hooks via ~/.zsh.after/ and ~/.zsh.before/ directories.
In these directories, you can place files to customize things that load before and after other zsh customizations that come from ~/.yadr/zsh/*
For example, to override the theme, you can do something like this:
```
mkdir ~/.zsh.after
echo "prompt skwp" > ~/.zsh.after/prompt.zsh
```

View File

@ -50,6 +50,11 @@ def install_prezto
puts "Installing YADR themes for Prezto..."
run %{ ln -nfs $HOME/.yadr/zsh/prezto-themes/modules/prompt/functions/* $HOME/.zprezto/modules/prompt/functions}
puts "Creating directories for your customizations"
run %{ mkdir -p $HOME/.zsh.before }
run %{ mkdir -p $HOME/.zsh.after }
run %{ mkdir -p $HOME/.zsh.prompts }
end
def want_to_install? (section)

View File

@ -1,4 +1,7 @@
# Load any user customizations prior to load
#
if [ -d $HOME/.zsh.before/ ]; then
for config_file ($HOME/.zsh.before/*.zsh) source $config_file
if [ "$(ls -A $HOME/.zsh.before/)" ]; then
for config_file ($HOME/.zsh.before/*.zsh) source $config_file
fi
fi

View File

@ -0,0 +1,3 @@
#Load themes from yadr and from user's custom prompts (themes) in ~/.zsh.prompts
fpath=($HOME/.yadr/zsh/prezto-themes $HOME/.zsh.prompts $fpath)
promptinit

View File

@ -1,4 +0,0 @@
modules/prompt/functions contains custom prompts for Prezto
These themes can be submitted to Prezto to be official. Until they are accepted, they can live here.
Learn more at: https://github.com/sorin-ionescu/prezto

View File

@ -1,4 +1,6 @@
# Load any custom after code
if [ -d $HOME/.zsh.after/ ]; then
for config_file ($HOME/.zsh.after/*.zsh) source $config_file
if [ "$(ls -A $HOME/.zsh.after/)" ]; then
for config_file ($HOME/.zsh.after/*.zsh) source $config_file
fi
fi