1
0
Fork 0
mirror of synced 2024-12-07 22:45:35 -05:00

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:
Eric Nielsen 2019-12-07 21:17:40 -05:00
parent c47c4fc08b
commit cec82ea0e5
No known key found for this signature in database
GPG key ID: 47D1DBFA0765A1FB
5 changed files with 48 additions and 33 deletions

View file

@ -55,73 +55,76 @@ If you have a different shell framework installed (like oh-my-zsh or prezto),
### Manual installation
1. Set Zsh as the default shell:
chsh -s =zsh
2. Start a Zsh shell
1. Start a Zsh shell
zsh
2. Set Zsh as the default shell:
chsh -s =zsh
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
`${ZDOTDIR:-${HOME}}` directory:
* [.zimrc](https://github.com/zimfw/install/blob/develop/src/templates/zimrc)
* [.zlogin](https://github.com/zimfw/install/blob/develop/src/templates/zlogin)
* [.zshrc](https://github.com/zimfw/install/blob/develop/src/templates/zshrc)
4. Add the lines in the following templates to the respective dot files:
* [~/.zimrc](https://github.com/zimfw/install/blob/develop/src/templates/zimrc)
* [~/.zlogin](https://github.com/zimfw/install/blob/develop/src/templates/zlogin)
* [~/.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
-----
### zmodule
Add `zmodule` calls to your `.zimrc` file to define the modules to be loaded.
The modules are loaded in the same order they are defined. Add:
Add `zmodule` calls to your `~/.zimrc` file to define the modules to be initialized.
The modules are initialized in the same order they are defined. Add:
zmodule <url> [-n|--name <module_name>] [options]
where &lt;url&gt; 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`.
By default, the module name is the last component in the &lt;url&gt;. Use the
`-n`|`--name` &lt;module_name&gt; option to set a custom module name.
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.
#### Repository options
* `-b`|`--branch` &lt;branch_name&gt;: 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`.
* `-t`|`--tag` &lt;tag_name&gt;: 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.
* `-z`|`--frozen`: Don't install or update the module.
* `-z|--frozen`: Don't install or update the module.
#### Startup options
#### Initialization options
* `-f`|`--fpath` &lt;path&gt;: 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.
* `-a`|`--autoload` &lt;function_name&gt;: Autoload specified function. Default: all
valid names inside all the module specified `fpath` paths.
* `-s`|`--source` &lt;file_path&gt;: Source specified file. The file path is relative
* `-a|--autoload <function_name>`: Autoload specified function. Default: all
valid names inside the module's specified `fpath` paths.
* `-s|--source <file_path>`: Source specified file. The file path is relative
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.
* `-d`|`--disabled`: Don't use or clean the module.
* `-d|--disabled`: Don't use or clean the module.
### zimfw
To install new defined modules, run:
Added new modules to `~/.zimrc`? Run:
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
To upgrade Zim, run:
Want to upgrade `~/.zim/zimfw.zsh` to the latest version?
zimfw upgrade

View file

@ -1,7 +1,7 @@
_zimfw_build() {
() {
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
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date"
fi

View file

@ -104,6 +104,11 @@ Startup options:
if (( zdisabled )); then
_zdisableds+=(${zmodule})
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))
if (( ! ${#zfunctions} )); then
# _* functions are autoloaded by compinit

View file

@ -44,6 +44,7 @@ Options:
case ${1} in
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
init) _zimfw_source_zimrc && _zimfw_build ;;
clean)
_zimfw_source_zimrc && \
_zimfw_clean_modules && \

View file

@ -49,7 +49,7 @@ fi
_zimfw_build() {
() {
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
print -PR "%F{green}✓%f %B${ztarget}:%b Already up to date"
fi
@ -179,6 +179,11 @@ Startup options:
if (( zdisabled )); then
_zdisableds+=(${zmodule})
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))
if (( ! ${#zfunctions} )); then
# _* functions are autoloaded by compinit
@ -250,7 +255,7 @@ _zimfw_clean_dumpfile() {
}
_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 'Zsh version: '${ZSH_VERSION}
print -R 'System info: '$(command uname -a)
@ -409,6 +414,7 @@ fi
case ${1} in
build) _zimfw_source_zimrc && _zimfw_build && _zimfw_compile ${2} ;;
init) _zimfw_source_zimrc && _zimfw_build ;;
clean)
_zimfw_source_zimrc && \
_zimfw_clean_modules && \