Optional async check for latest version
every 30 days, storing it in a .latest_version file. Also allow disabling this with: zstyle ':zim' disable-version-check yes
This commit is contained in:
parent
7fdf65c58f
commit
1341afe525
7 changed files with 64 additions and 35 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,6 +2,7 @@
|
|||
*.zwc
|
||||
*.zwc.old
|
||||
/modules/
|
||||
.latest_version
|
||||
/init.zsh
|
||||
/init.zsh.old
|
||||
/login_init.zsh
|
||||
|
|
|
@ -10,7 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Added
|
||||
- `help` and `version` actions.
|
||||
- `-v` verbose option. Normal mode output is now cleaner and more focused.
|
||||
- Check the latest version using `git ls-remote`.
|
||||
- Asynchronously check the latest version every 30 days. This can be disabled
|
||||
with `zstyle ':zim' disable-version-check yes`.
|
||||
|
||||
### Changed
|
||||
- When upgrading, download latest release asset instead of raw file from the
|
||||
|
|
32
README.md
32
README.md
|
@ -48,7 +48,7 @@ Installing Zim is easy:
|
|||
wget -nv -O - https://raw.githubusercontent.com/zimfw/install/master/install.zsh | zsh
|
||||
|
||||
Open a new terminal and you're done! Enjoy your Zsh IMproved! Take some time to
|
||||
read about the [available modules] and tweak your `.zshrc` file.
|
||||
read about the [available modules] and tweak your `~/.zshrc` file.
|
||||
|
||||
If you have a different shell framework installed (like oh-my-zsh or prezto),
|
||||
*uninstall those first to prevent conflicts*.
|
||||
|
@ -92,7 +92,7 @@ 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
|
||||
`-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
|
||||
updating the module. Overrides the tag option. Default: `master`.
|
||||
|
@ -100,7 +100,7 @@ By default, the module name is the last component in the `<url>`. Use the
|
|||
module. Overrides the branch option.
|
||||
* `-z|--frozen`: Don't install or update the module.
|
||||
|
||||
#### Initialization options
|
||||
Initialization options:
|
||||
|
||||
* `-f|--fpath <path>`: Add specified path to `fpath`. The path is relative to
|
||||
the module root directory. Default: `functions`, if the subdirectory exists.
|
||||
|
@ -109,28 +109,28 @@ By default, the module name is the last component in the `<url>`. Use the
|
|||
* `-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 uninstall the module.
|
||||
* `-d|--disabled`: Don't initialize or uninstall the module.
|
||||
|
||||
### zimfw
|
||||
|
||||
Added new modules to `~/.zimrc`? Run:
|
||||
Added new modules to `~/.zimrc`? Run `zimfw install`.
|
||||
|
||||
zimfw install
|
||||
Removed modules from `~/.zimrc`? Run `zimfw uninstall`.
|
||||
|
||||
Removed modules from `~/.zimrc`? Run:
|
||||
Want to update your modules to their latest revisions? Run `zimfw update`.
|
||||
|
||||
zimfw uninstall
|
||||
|
||||
Want to update your modules to their latest revisions? Run:
|
||||
|
||||
zimfw update
|
||||
|
||||
Want to upgrade `~/.zim/zimfw.zsh` to the latest version? Run:
|
||||
|
||||
zimfw upgrade
|
||||
Want to upgrade `zimfw` to its latest version? Run `zimfw upgrade`.
|
||||
|
||||
For more information about the `zimfw` tool, run `zimfw help`.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
By default, every 30 days `zimfw` will check if it has a new version available.
|
||||
This can be disabled with:
|
||||
|
||||
zstyle ':zim' disable-version-check yes
|
||||
|
||||
Uninstalling
|
||||
------------
|
||||
|
||||
|
|
16
src/stage2/40_zimfw_version_check.zsh.erb
Normal file
16
src/stage2/40_zimfw_version_check.zsh.erb
Normal file
|
@ -0,0 +1,16 @@
|
|||
_zimfw_version_check() {
|
||||
if (( _zprintlevel > 0 )); then
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
local -r ztarget=${ZIM_HOME}/.latest_version
|
||||
# If .latest_version does not exist or was not modified in the last 30 days
|
||||
if [[ ! -f ${ztarget}(#qNm-30) ]]; then
|
||||
command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*' | \
|
||||
command sed 's?^.*/v??' | command sort -n -t. -k1,1 -k2,2 -k3,3 | \
|
||||
command tail -n1 >! ${ztarget} &!
|
||||
fi
|
||||
local -r zlatest_version=$(<${ztarget})
|
||||
if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; then
|
||||
print -PR "%F{yellow}Latest zimfw version is %B${zlatest_version}%b. You're using version %B${_zversion}%b. Run %Bzimfw upgrade%b to upgrade.%f"$'\n'
|
||||
fi
|
||||
fi
|
||||
}
|
|
@ -1,6 +1,6 @@
|
|||
_zimfw_info() {
|
||||
print -R 'Zim version: '${_zversion}' (previous commit is <%= `git rev-parse --short HEAD | tr -d '\r\n'` %>)'
|
||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||
print -R 'Zsh version: '${ZSH_VERSION}
|
||||
print -R 'System info: '$(command uname -a)
|
||||
print -R 'zimfw version: '${_zversion}' (previous commit is <%= `git rev-parse --short HEAD | tr -d '\r\n'` %>)'
|
||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||
print -R 'Zsh version: '${ZSH_VERSION}
|
||||
print -R 'System info: '$(command uname -a)
|
||||
}
|
||||
|
|
|
@ -37,11 +37,8 @@ Options:
|
|||
esac
|
||||
fi
|
||||
|
||||
if (( _zprintlevel > 0 )); then
|
||||
local -r zlatestversion=$(command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*' | sed 's?^.*/v??' | sort -n -t. -k1,1 -k2,2 -k3,3 | tail -n1)
|
||||
if [[ ${_zversion} != ${zlatestversion} ]]; then
|
||||
print -PR "%F{yellow}Latest zimfw version is %B${zlatestversion}%b. You're using version %B${_zversion}%b. Run %Bzimfw upgrade%b to upgrade.%f"$'\n'
|
||||
fi
|
||||
if ! zstyle -t ':zim' disable-version-check; then
|
||||
_zimfw_version_check
|
||||
fi
|
||||
|
||||
case ${1} in
|
||||
|
|
32
zimfw.zsh
32
zimfw.zsh
|
@ -236,6 +236,23 @@ _zimfw_source_zimrc() {
|
|||
fi
|
||||
}
|
||||
|
||||
_zimfw_version_check() {
|
||||
if (( _zprintlevel > 0 )); then
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
local -r ztarget=${ZIM_HOME}/.latest_version
|
||||
# If .latest_version does not exist or was not modified in the last 30 days
|
||||
if [[ ! -f ${ztarget}(#qNm-30) ]]; then
|
||||
command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*' | \
|
||||
command sed 's?^.*/v??' | command sort -n -t. -k1,1 -k2,2 -k3,3 | \
|
||||
command tail -n1 >! ${ztarget} &!
|
||||
fi
|
||||
local -r zlatest_version=$(<${ztarget})
|
||||
if [[ -n ${zlatest_version} && ${_zversion} != ${zlatest_version} ]]; then
|
||||
print -PR "%F{yellow}Latest zimfw version is %B${zlatest_version}%b. You're using version %B${_zversion}%b. Run %Bzimfw upgrade%b to upgrade.%f"$'\n'
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
_zimfw_clean_compiled() {
|
||||
local zopt
|
||||
(( _zprintlevel > 0 )) && zopt='-v'
|
||||
|
@ -259,10 +276,10 @@ _zimfw_compile() {
|
|||
}
|
||||
|
||||
_zimfw_info() {
|
||||
print -R 'Zim version: '${_zversion}' (previous commit is be2be83)'
|
||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||
print -R 'Zsh version: '${ZSH_VERSION}
|
||||
print -R 'System info: '$(command uname -a)
|
||||
print -R 'zimfw version: '${_zversion}' (previous commit is 7fdf65c)'
|
||||
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||
print -R 'Zsh version: '${ZSH_VERSION}
|
||||
print -R 'System info: '$(command uname -a)
|
||||
}
|
||||
|
||||
_zimfw_uninstall() {
|
||||
|
@ -338,11 +355,8 @@ Options:
|
|||
esac
|
||||
fi
|
||||
|
||||
if (( _zprintlevel > 0 )); then
|
||||
local -r zlatestversion=$(command git ls-remote --tags --refs https://github.com/zimfw/zimfw.git 'v*' | sed 's?^.*/v??' | sort -n -t. -k1,1 -k2,2 -k3,3 | tail -n1)
|
||||
if [[ ${_zversion} != ${zlatestversion} ]]; then
|
||||
print -PR "%F{yellow}Latest zimfw version is %B${zlatestversion}%b. You're using version %B${_zversion}%b. Run %Bzimfw upgrade%b to upgrade.%f"$'\n'
|
||||
fi
|
||||
if ! zstyle -t ':zim' disable-version-check; then
|
||||
_zimfw_version_check
|
||||
fi
|
||||
|
||||
case ${1} in
|
||||
|
|
Loading…
Reference in a new issue