Add zimfw init action for a quick build
Having to manually do `zimfw build` every time after you edit your .zimrc file is boring. So by having the following in .zshrc before sourcing init.zsh will do a quick build automatically when needed: if [[ ~/.zim/init.zsh -ot ~/.zimrc ]]; then source ~/.zim/zimfw.zsh init -q fi
This commit is contained in:
parent
c47c4fc08b
commit
cec82ea0e5
5 changed files with 48 additions and 33 deletions
63
README.md
63
README.md
|
@ -55,73 +55,76 @@ If you have a different shell framework installed (like oh-my-zsh or prezto),
|
||||||
|
|
||||||
### Manual installation
|
### Manual installation
|
||||||
|
|
||||||
1. Set Zsh as the default shell:
|
1. Start a Zsh shell
|
||||||
|
|
||||||
chsh -s =zsh
|
|
||||||
|
|
||||||
2. Start a Zsh shell
|
|
||||||
|
|
||||||
zsh
|
zsh
|
||||||
|
|
||||||
|
2. Set Zsh as the default shell:
|
||||||
|
|
||||||
|
chsh -s =zsh
|
||||||
|
|
||||||
3. Copy https://raw.githubusercontent.com/zimfw/zimfw/develop/zimfw.zsh to
|
3. Copy https://raw.githubusercontent.com/zimfw/zimfw/develop/zimfw.zsh to
|
||||||
`${ZDOTDIR:-${HOME}}/.zim/zimfw.zsh`.
|
`~/.zim/zimfw.zsh`.
|
||||||
|
|
||||||
4. Add the lines in the following templates to the respective dot files in the
|
4. Add the lines in the following templates to the respective dot files:
|
||||||
`${ZDOTDIR:-${HOME}}` directory:
|
* [~/.zimrc](https://github.com/zimfw/install/blob/develop/src/templates/zimrc)
|
||||||
* [.zimrc](https://github.com/zimfw/install/blob/develop/src/templates/zimrc)
|
* [~/.zlogin](https://github.com/zimfw/install/blob/develop/src/templates/zlogin)
|
||||||
* [.zlogin](https://github.com/zimfw/install/blob/develop/src/templates/zlogin)
|
* [~/.zshrc](https://github.com/zimfw/install/blob/develop/src/templates/zshrc)
|
||||||
* [.zshrc](https://github.com/zimfw/install/blob/develop/src/templates/zshrc)
|
|
||||||
|
|
||||||
5. Install the modules defined in `.zimrc` and build the static `init.zsh` script:
|
5. Install the modules defined in `~/.zimrc` and build the static initialization script:
|
||||||
|
|
||||||
source ${ZDOTDIR:-${HOME}}/.zim/zimfw.zsh install
|
source ~/.zim/zimfw.zsh install
|
||||||
|
|
||||||
Usage
|
Usage
|
||||||
-----
|
-----
|
||||||
|
|
||||||
### zmodule
|
### zmodule
|
||||||
|
|
||||||
Add `zmodule` calls to your `.zimrc` file to define the modules to be loaded.
|
Add `zmodule` calls to your `~/.zimrc` file to define the modules to be initialized.
|
||||||
The modules are loaded in the same order they are defined. Add:
|
The modules are initialized in the same order they are defined. Add:
|
||||||
|
|
||||||
zmodule <url> [-n|--name <module_name>] [options]
|
zmodule <url> [-n|--name <module_name>] [options]
|
||||||
|
|
||||||
where <url> is the required repository URL or path. The following formats
|
where `<url>` is the required repository URL or path. The following formats
|
||||||
are equivalent: `name`, `zimfw/name`, `https://github.com/zimfw/name.git`.
|
are equivalent: `name`, `zimfw/name`, `https://github.com/zimfw/name.git`.
|
||||||
|
|
||||||
By default, the module name is the last component in the <url>. Use the
|
By default, the module name is the last component in the `<url>`. Use the
|
||||||
`-n`|`--name` <module_name> option to set a custom module name.
|
`-n|--name <module_name>` option to set a custom module name.
|
||||||
|
|
||||||
#### Repository options
|
#### Repository options
|
||||||
|
|
||||||
* `-b`|`--branch` <branch_name>: Use specified branch when installing and
|
* `-b|--branch <branch_name>`: Use specified branch when installing and
|
||||||
updating the module. Overrides the tag option. Default: `master`.
|
updating the module. Overrides the tag option. Default: `master`.
|
||||||
* `-t`|`--tag` <tag_name>: Use specified tag when installing and updating the
|
* `-t|--tag <tag_name>`: Use specified tag when installing and updating the
|
||||||
module. Overrides the branch option.
|
module. Overrides the branch option.
|
||||||
* `-z`|`--frozen`: Don't install or update the module.
|
* `-z|--frozen`: Don't install or update the module.
|
||||||
|
|
||||||
#### Startup options
|
#### Initialization options
|
||||||
|
|
||||||
* `-f`|`--fpath` <path>: Add specified path to `fpath`. The path is relative to
|
* `-f|--fpath <path>`: Add specified path to `fpath`. The path is relative to
|
||||||
the module root directory. Default: `functions`, if the subdirectory exists.
|
the module root directory. Default: `functions`, if the subdirectory exists.
|
||||||
* `-a`|`--autoload` <function_name>: Autoload specified function. Default: all
|
* `-a|--autoload <function_name>`: Autoload specified function. Default: all
|
||||||
valid names inside all the module specified `fpath` paths.
|
valid names inside the module's specified `fpath` paths.
|
||||||
* `-s`|`--source` <file_path>: Source specified file. The file path is relative
|
* `-s|--source <file_path>`: Source specified file. The file path is relative
|
||||||
to the module root directory. Default: the file with largest size matching
|
to the module root directory. Default: the file with largest size matching
|
||||||
`{init.zsh|module_name.{zsh|plugin.zsh|zsh-theme|sh}}`, if any exists.
|
`{init.zsh|module_name.{zsh|plugin.zsh|zsh-theme|sh}}`, if any exists.
|
||||||
* `-d`|`--disabled`: Don't use or clean the module.
|
* `-d|--disabled`: Don't use or clean the module.
|
||||||
|
|
||||||
### zimfw
|
### zimfw
|
||||||
|
|
||||||
To install new defined modules, run:
|
Added new modules to `~/.zimrc`? Run:
|
||||||
|
|
||||||
zimfw install
|
zimfw install
|
||||||
|
|
||||||
To update your modules, run:
|
Removed modules from `~/.zimrc`? Run:
|
||||||
|
|
||||||
|
zimfw clean-modules
|
||||||
|
|
||||||
|
Want to update your modules to their latest revisions? Run:
|
||||||
|
|
||||||
zimfw update
|
zimfw update
|
||||||
|
|
||||||
To upgrade Zim, run:
|
Want to upgrade `~/.zim/zimfw.zsh` to the latest version?
|
||||||
|
|
||||||
zimfw upgrade
|
zimfw upgrade
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
_zimfw_build() {
|
_zimfw_build() {
|
||||||
() {
|
() {
|
||||||
local -r ztarget=${ZIM_HOME}/init.zsh
|
local -r ztarget=${ZIM_HOME}/init.zsh
|
||||||
if command cmp -s ${ztarget} ${1}; then
|
if [[ ${ztarget} -nt <%= home %>/.zimrc ]] && command cmp -s ${ztarget} ${1}; then
|
||||||
if (( ! _zquiet )); then
|
if (( ! _zquiet )); then
|
||||||
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date"
|
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date"
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -104,6 +104,11 @@ Startup options:
|
||||||
if (( zdisabled )); then
|
if (( zdisabled )); then
|
||||||
_zdisableds+=(${zmodule})
|
_zdisableds+=(${zmodule})
|
||||||
else
|
else
|
||||||
|
if [[ ! -d ${zdir} ]]; then
|
||||||
|
print -u2 -PR "%F{red}✗ ${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
|
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
|
||||||
if (( ! ${#zfunctions} )); then
|
if (( ! ${#zfunctions} )); then
|
||||||
# _* functions are autoloaded by compinit
|
# _* functions are autoloaded by compinit
|
||||||
|
|
|
@ -44,6 +44,7 @@ Options:
|
||||||
|
|
||||||
case ${1} in
|
case ${1} in
|
||||||
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
|
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
|
||||||
|
init) _zimfw_source_zimrc && _zimfw_build ;;
|
||||||
clean)
|
clean)
|
||||||
_zimfw_source_zimrc && \
|
_zimfw_source_zimrc && \
|
||||||
_zimfw_clean_modules && \
|
_zimfw_clean_modules && \
|
||||||
|
|
10
zimfw.zsh
10
zimfw.zsh
|
@ -49,7 +49,7 @@ fi
|
||||||
_zimfw_build() {
|
_zimfw_build() {
|
||||||
() {
|
() {
|
||||||
local -r ztarget=${ZIM_HOME}/init.zsh
|
local -r ztarget=${ZIM_HOME}/init.zsh
|
||||||
if command cmp -s ${ztarget} ${1}; then
|
if [[ ${ztarget} -nt ${ZDOTDIR:-${HOME}}/.zimrc ]] && command cmp -s ${ztarget} ${1}; then
|
||||||
if (( ! _zquiet )); then
|
if (( ! _zquiet )); then
|
||||||
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date"
|
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date"
|
||||||
fi
|
fi
|
||||||
|
@ -179,6 +179,11 @@ Startup options:
|
||||||
if (( zdisabled )); then
|
if (( zdisabled )); then
|
||||||
_zdisableds+=(${zmodule})
|
_zdisableds+=(${zmodule})
|
||||||
else
|
else
|
||||||
|
if [[ ! -d ${zdir} ]]; then
|
||||||
|
print -u2 -PR "%F{red}✗ ${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
|
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
|
||||||
if (( ! ${#zfunctions} )); then
|
if (( ! ${#zfunctions} )); then
|
||||||
# _* functions are autoloaded by compinit
|
# _* functions are autoloaded by compinit
|
||||||
|
@ -250,7 +255,7 @@ _zimfw_clean_dumpfile() {
|
||||||
}
|
}
|
||||||
|
|
||||||
_zimfw_info() {
|
_zimfw_info() {
|
||||||
print 'Zim version: 1.0.0-SNAPSHOT (previous commit is bccb1fc)'
|
print 'Zim version: 1.0.0-SNAPSHOT (previous commit is c330f61)'
|
||||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||||
print -R 'Zsh version: '${ZSH_VERSION}
|
print -R 'Zsh version: '${ZSH_VERSION}
|
||||||
print -R 'System info: '$(command uname -a)
|
print -R 'System info: '$(command uname -a)
|
||||||
|
@ -409,6 +414,7 @@ fi
|
||||||
|
|
||||||
case ${1} in
|
case ${1} in
|
||||||
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
|
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
|
||||||
|
init) _zimfw_source_zimrc && _zimfw_build ;;
|
||||||
clean)
|
clean)
|
||||||
_zimfw_source_zimrc && \
|
_zimfw_source_zimrc && \
|
||||||
_zimfw_clean_modules && \
|
_zimfw_clean_modules && \
|
||||||
|
|
Loading…
Reference in a new issue