Add a plugin mechanism \o/
This is a major change, where Zsh modules/plugins are not git submodules in the Zim repo anymore, but customized and installed separately as individual repositories. The discussion about this started more than 2 years ago in #88. Closes #299. This will allow contributors' modules to live in their own repositories. See #33, #138, #262, #281, #324. The current code has what, up to this point, I considered to be the best balance between simplicity, execution speed and number of files. One measured decision was to make the initialization of modules depend only on the `':zim' modules` style, keeping it as fast as possible. The `':zim:module' module` style is used to install, update and clean the modules, all operations that happen after the user got his as-blazing-fast-possible shell prompt. Even though I didn't care much about making install or update fast, `xargs` has a nice feature of allowing commands to be executed in parallel with `-P`. I took advantage of that. I've also worked on making the `zimfw` utility give the user some nice (while still minimalistic) output. Also I'm suggesting this as the new name for the `zmanage` tool, since `zimfw` does not shadow the `zim` wiki tool.
This commit is contained in:
parent
5371975f37
commit
8dc3e43a0d
101 changed files with 401 additions and 3515 deletions
28
.gitmodules
vendored
28
.gitmodules
vendored
|
@ -1,28 +0,0 @@
|
|||
[submodule "modules/history-substring-search/external"]
|
||||
path = modules/history-substring-search/external
|
||||
url = https://github.com/zsh-users/zsh-history-substring-search.git
|
||||
ignore = untracked
|
||||
[submodule "modules/completion/external"]
|
||||
path = modules/completion/external
|
||||
url = https://github.com/zsh-users/zsh-completions.git
|
||||
ignore = untracked
|
||||
[submodule "modules/syntax-highlighting/external"]
|
||||
path = modules/syntax-highlighting/external
|
||||
url = https://github.com/zsh-users/zsh-syntax-highlighting.git
|
||||
ignore = untracked
|
||||
[submodule "modules/prompt/external-themes/pure"]
|
||||
path = modules/prompt/external-themes/pure
|
||||
url = https://github.com/sindresorhus/pure.git
|
||||
ignore = untracked
|
||||
[submodule "modules/prompt/external-themes/liquidprompt"]
|
||||
path = modules/prompt/external-themes/liquidprompt
|
||||
url = https://github.com/nojhan/liquidprompt.git
|
||||
ignore = untracked
|
||||
[submodule "modules/prompt/external-themes/lean"]
|
||||
path = modules/prompt/external-themes/lean
|
||||
url = https://github.com/miekg/lean
|
||||
ignore = untracked
|
||||
[submodule "modules/autosuggestions/external"]
|
||||
path = modules/autosuggestions/external
|
||||
url = https://github.com/zsh-users/zsh-autosuggestions.git
|
||||
ignore = untracked
|
95
README.md
95
README.md
|
@ -59,20 +59,92 @@ Installing Zim is easy. If you have a different shell framework installed (like
|
|||
|
||||
chsh -s =zsh
|
||||
|
||||
5. Open a new terminal and finish optimization (this is only needed once, hereafter it will happen upon desktop/tty login):
|
||||
5. Open a new terminal and install the enabled modules.
|
||||
|
||||
source ${ZDOTDIR:-${HOME}}/.zlogin
|
||||
zimfw install
|
||||
|
||||
6. You're done! Enjoy your Zsh IMproved! Take some time to read about the [available modules][modules] and tweak your `.zshrc` file.
|
||||
6. Finish optimization (this is only needed once, hereafter it will happen upon
|
||||
desktop/tty login):
|
||||
|
||||
zimfw login-init
|
||||
|
||||
7. You're done! Enjoy your Zsh IMproved! Take some time to read about the
|
||||
[available modules][modules] and tweak your `.zshrc` file.
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
### Enabled modules
|
||||
|
||||
Use the following zstyle to select the modules you would like enabled:
|
||||
|
||||
zstyle ':zim' modules 'first-module' 'second-module' 'third-module'
|
||||
|
||||
You can provide as many module names as you want. Modules are sourced in the
|
||||
order given.
|
||||
|
||||
By default, a module is installed from the Zim repository with the same name.
|
||||
For example, the `git` module is installed from https://github.com/zimfw/git if
|
||||
no additional module configuration is provided.
|
||||
|
||||
### Module customization
|
||||
|
||||
To configure a module, use the following format (where the style name is the
|
||||
module name):
|
||||
|
||||
zstyle ':zim:module' <module> ['frozen' yes] ['url' <url>] ['branch' <branch>|'tag' <tag>]
|
||||
|
||||
If `frozen` is set to `yes`, then the module will not be cleaned, installed or
|
||||
updated.
|
||||
|
||||
You can provide a custom `url` with the following equivalent formats:
|
||||
* `module`
|
||||
* `zimfw/module`
|
||||
* `https://github.com/zimfw/module.git`
|
||||
|
||||
If no `branch` or `tag` name is given, then the default is `branch` `master`.
|
||||
|
||||
Choose the module name wisely. The first file found in the module root directory,
|
||||
in the following order, will be sourced (where `module` is the module name):
|
||||
1. `init.zsh`
|
||||
2. `module.zsh`
|
||||
3. `module.plugin.zsh`
|
||||
4. `module.zsh.theme`
|
||||
5. `module.sh`
|
||||
|
||||
For example, https://github.com/mafredri/zsh-async must be configured as:
|
||||
|
||||
zstyle ':zim:module' async 'url' 'mafredri/zsh-async'
|
||||
|
||||
because it has a `async.zsh` initialization file, then enabled as `async` in the
|
||||
`modules` style.
|
||||
|
||||
### Prompt theme
|
||||
|
||||
Prompt themes are enabled in one of two different ways, depending on how the
|
||||
specific theme you want works:
|
||||
|
||||
1. If it has a `prompt_module_setup` file (where `module` is the module name):
|
||||
it is enabled with Zim's `prompt` module. See [the instructions
|
||||
here](https://github.com/zimfw/prompt/blob/master/README.md#settings). The
|
||||
advantage of these themes is that you can customize them with additional
|
||||
parameters. All [Zim themes](https://github.com/zimfw/zimfw/wiki/Themes)
|
||||
work this way.
|
||||
2. If it has one of the initialization files listed above: it is enabled when
|
||||
it's sourced, not with Zim's `prompt` module.
|
||||
|
||||
Updating
|
||||
--------
|
||||
|
||||
To update Zim, run:
|
||||
To update your modules, run:
|
||||
|
||||
zmanage update
|
||||
zimfw update
|
||||
|
||||
For more information about the `zmanage` tool, run `zmanage help`.
|
||||
To upgrade Zim, run:
|
||||
|
||||
zimfw upgrade
|
||||
|
||||
For more information about the `zimfw` tool, run `zimfw` with no parameters.
|
||||
|
||||
Uninstalling
|
||||
------------
|
||||
|
@ -80,17 +152,6 @@ Uninstalling
|
|||
The best way to remove Zim is to manually delete `~/.zim`, `~/.zimrc`, and
|
||||
remove the initialization lines from your `~/.zshrc` and `~/.zlogin`.
|
||||
|
||||
However, there are some **experimental** convenience functions to remove Zim:
|
||||
|
||||
**NOTE: This functionality is experimental!**
|
||||
|
||||
To remove Zim, run:
|
||||
|
||||
zmanage remove
|
||||
|
||||
**NOTE: This functionality is experimental!**
|
||||
|
||||
|
||||
[fish_shell]: https://i.eriner.me/zim_history-substring-search.gif
|
||||
[syntax_highlighting]: https://i.eriner.me/zim_syntax-highlighting.gif
|
||||
[speed]: https://github.com/zimfw/zimfw/wiki/Speed
|
||||
|
|
142
init.zsh
Executable file → Normal file
142
init.zsh
Executable file → Normal file
|
@ -1,51 +1,50 @@
|
|||
#
|
||||
# Zim initializition
|
||||
#
|
||||
|
||||
autoload -Uz is-at-least && if ! is-at-least 5.2; then
|
||||
print "ERROR: Zim didn't start. You're using zsh version ${ZSH_VERSION}, and versions < 5.2 are not supported. Update your zsh." >&2
|
||||
print "init: error starting Zim: You're using Zsh version ${ZSH_VERSION} and versions < 5.2 are not supported. Update your Zsh." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Define zim location
|
||||
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
||||
# Define Zim location
|
||||
: ${ZIM_HOME=${0:h}}
|
||||
|
||||
# Source user configuration
|
||||
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
||||
[[ -f ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
||||
|
||||
# Set input mode before loading modules
|
||||
if [[ ${zinput_mode} == 'vi' ]]; then
|
||||
if zstyle -t ':zim:input' mode 'vi'; then
|
||||
bindkey -v
|
||||
else
|
||||
bindkey -e
|
||||
fi
|
||||
|
||||
# Autoload module functions
|
||||
# Autoload enabled modules' functions
|
||||
() {
|
||||
local mod_function
|
||||
local zfunction
|
||||
local -a zmodules
|
||||
zstyle -a ':zim' modules 'zmodules'
|
||||
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
|
||||
# autoload searches fpath for function locations; add enabled module function paths
|
||||
fpath=(${ZIM_HOME}/modules/${^zmodules}/functions(/FN) ${fpath})
|
||||
|
||||
for mod_function in ${ZIM_HOME}/modules/${^zmodules}/functions/^(_*|prompt_*_setup|*.*)(-.N:t); do
|
||||
autoload -Uz ${mod_function}
|
||||
for zfunction in ${ZIM_HOME}/modules/${^zmodules}/functions/^(_*|*.*|prompt_*_setup)(-.N:t); do
|
||||
autoload -Uz ${zfunction}
|
||||
done
|
||||
}
|
||||
|
||||
# Initialize modules
|
||||
# Source enabled modules' init scripts
|
||||
() {
|
||||
local zmodule zmodule_dir zmodule_file
|
||||
local zmodule zdir zfile
|
||||
local -a zmodules
|
||||
zstyle -a ':zim' modules 'zmodules'
|
||||
|
||||
for zmodule in ${zmodules}; do
|
||||
zmodule_dir=${ZIM_HOME}/modules/${zmodule}
|
||||
if [[ ! -d ${zmodule_dir} ]]; then
|
||||
print "No such module \"${zmodule}\"." >&2
|
||||
zdir=${ZIM_HOME}/modules/${zmodule}
|
||||
if [[ ! -d ${zdir} ]]; then
|
||||
print "init: module ${zmodule} not installed" >&2
|
||||
elif [[ -f ${zdir}/prompt_${zmodule}_setup ]]; then
|
||||
fpath=(${zdir} ${fpath}) # Will be loaded by promptinit
|
||||
else
|
||||
for zmodule_file in ${zmodule_dir}/init.zsh \
|
||||
${zmodule_dir}/{,zsh-}${zmodule}.{zsh,plugin.zsh,zsh-theme,sh}; do
|
||||
if [[ -f ${zmodule_file} ]]; then
|
||||
source ${zmodule_file}
|
||||
for zfile in ${zdir}/init.zsh ${zdir}/${zmodule}.{zsh,plugin.zsh,zsh-theme,sh}; do
|
||||
if [[ -f ${zfile} ]]; then
|
||||
source ${zfile}
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
@ -53,42 +52,71 @@ fi
|
|||
done
|
||||
}
|
||||
|
||||
zmanage() {
|
||||
local usage="zmanage [action]
|
||||
Actions:
|
||||
update Fetch and merge upstream zim commits if possible
|
||||
info Print zim and system info
|
||||
issue Create a template for reporting an issue
|
||||
clean-cache Clean the zim cache
|
||||
build-cache Rebuild the zim cache
|
||||
remove *experimental* Remove zim as best we can
|
||||
reset Reset zim to the latest commit
|
||||
debug Invoke the trace-zim script which produces logs
|
||||
help Print this usage message"
|
||||
_zimfw_compile() {
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
autoload -U zrecompile
|
||||
|
||||
if (( ${#} != 1 )); then
|
||||
print ${usage}
|
||||
local zdir zfile
|
||||
local -a zmodules
|
||||
zstyle -a ':zim' modules 'zmodules'
|
||||
|
||||
# Compile the completion cache; significant speedup
|
||||
local zdumpfile
|
||||
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile="${ZDOTDIR:-${HOME}}/.zcompdump"
|
||||
[[ -f ${zdumpfile} ]] && zrecompile -p ${1} ${zdumpfile}
|
||||
|
||||
# Compile .zshrc
|
||||
zrecompile -p ${1} ${ZDOTDIR:-${HOME}}/.zshrc
|
||||
|
||||
# Compile enabled modules' autoloaded functions
|
||||
for zdir in ${ZIM_HOME}/modules/${^zmodules}/functions(/FN); do
|
||||
zrecompile -p ${1} ${zdir}.zwc ${zdir}/^(_*|*.*|prompt_*_setup)(-.N)
|
||||
done
|
||||
|
||||
# Compile enabled modules' scripts
|
||||
for zfile in ${ZIM_HOME}/modules/${^zmodules}/(^*test*/)#{*.zsh{,-theme},prompt_*_setup}(.NLk+1); do
|
||||
zrecompile -p ${1} ${zfile}
|
||||
done
|
||||
|
||||
# Compile this script
|
||||
zrecompile -p ${1} ${ZIM_HOME}/init.zsh
|
||||
|
||||
if [[ ${1} != -q ]]; then
|
||||
print -P '%F{green}✓%f Done with compile.'
|
||||
fi
|
||||
}
|
||||
|
||||
zimfw() {
|
||||
if [[ ${#} -ne 1 && ${2} != -q ]]; then
|
||||
source ${ZIM_HOME}/tools/usage.zsh
|
||||
return 1
|
||||
fi
|
||||
|
||||
case ${1} in
|
||||
update) zsh ${ZIM_HOME}/tools/zim_update
|
||||
;;
|
||||
info) zsh ${ZIM_HOME}/tools/zim_info
|
||||
;;
|
||||
issue) zsh ${ZIM_HOME}/tools/zim_issue
|
||||
;;
|
||||
clean-cache) source ${ZIM_HOME}/tools/zim_clean_cache && print 'Cache cleaned'
|
||||
;;
|
||||
build-cache) source ${ZIM_HOME}/tools/zim_build_cache && print 'Cache rebuilt'
|
||||
;;
|
||||
remove) zsh ${ZIM_HOME}/tools/zim_remove
|
||||
;;
|
||||
reset) zsh ${ZIM_HOME}/tools/zim_reset
|
||||
;;
|
||||
debug) zsh ${ZIM_HOME}/modules/debug/functions/trace-zim
|
||||
;;
|
||||
*) print ${usage}; return 1
|
||||
;;
|
||||
clean)
|
||||
source ${ZIM_HOME}/tools/clean-modules.zsh ${2} && \
|
||||
source ${ZIM_HOME}/tools/clean-compiled.zsh ${2} && \
|
||||
source ${ZIM_HOME}/tools/clean-dumpfile.zsh ${2}
|
||||
;;
|
||||
clean-modules) source ${ZIM_HOME}/tools/clean-modules.zsh ${2} ;;
|
||||
clean-compiled) source ${ZIM_HOME}/tools/clean-compiled.zsh ${2} ;;
|
||||
clean-dumpfile) source ${ZIM_HOME}/tools/clean-dumpfile.zsh ${2} ;;
|
||||
compile|login-init) _zimfw_compile ${2} ;;
|
||||
info) source ${ZIM_HOME}/tools/info.zsh ${2} ;;
|
||||
install|update)
|
||||
# Source .zimrc to refresh zmodules
|
||||
[[ -f ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
||||
source ${ZIM_HOME}/tools/modules.zsh ${2} | xargs -L1 -P10 zsh ${ZIM_HOME}/tools/${1}.zsh && \
|
||||
if [[ ${2} != -q ]]; then
|
||||
print -P "%F{green}✓%f Done with ${1}. Restart your terminal for any changes to take effect."
|
||||
fi
|
||||
;;
|
||||
upgrade)
|
||||
zsh ${ZIM_HOME}/tools/update.zsh 'https://github.com/zimfw/zimfw.git' ${ZIM_HOME} branch develop ${2}
|
||||
;;
|
||||
*)
|
||||
source ${ZIM_HOME}/tools/usage.zsh
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
|
34
login_init.zsh
Executable file → Normal file
34
login_init.zsh
Executable file → Normal file
|
@ -1,33 +1 @@
|
|||
#
|
||||
# startup file read in interactive login shells
|
||||
#
|
||||
# The following code helps us by optimizing the existing framework.
|
||||
# This includes zcompile, zcompdump, etc.
|
||||
#
|
||||
|
||||
(
|
||||
local dir file
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
autoload -U zrecompile
|
||||
|
||||
# zcompile the completion cache; siginificant speedup
|
||||
zrecompile -pq ${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}
|
||||
|
||||
# zcompile .zshrc
|
||||
zrecompile -pq ${ZDOTDIR:-${HOME}}/.zshrc
|
||||
|
||||
# zcompile enabled module autoloaded functions
|
||||
for dir in ${ZIM_HOME}/modules/${^zmodules}/functions(/FN); do
|
||||
zrecompile -pq ${dir}.zwc ${dir}/^(_*|prompt_*_setup|*.*)(-.N)
|
||||
done
|
||||
|
||||
# zcompile enabled module scripts
|
||||
for file in ${ZIM_HOME}/modules/${^zmodules}/(^*test*/)#*.zsh{,-theme}(.NLk+1); do
|
||||
zrecompile -pq ${file}
|
||||
done
|
||||
|
||||
# zcompile all prompt setup scripts
|
||||
for file in ${ZIM_HOME}/modules/prompt/functions/prompt_*_setup; do
|
||||
zrecompile -pq ${file}
|
||||
done
|
||||
) &!
|
||||
zimfw login-init -q &!
|
||||
|
|
|
@ -1,31 +0,0 @@
|
|||
archive
|
||||
=======
|
||||
|
||||
Provides `archive` and `unarchive` functions for easy archive manipulation.
|
||||
|
||||
This module will make use of `pigz` and `pbzip2` if available to make use of all available CPU cores.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
* `archive` generates an archive based on file extension. Syntax is `archive myarchive.tar.gz /path/to/archive`
|
||||
* `unarchive` unarchives files based on the extensions. Syntax is `unarchive myarchive.7z`
|
||||
|
||||
Archive formats
|
||||
---------------
|
||||
|
||||
| Format | Requirements |
|
||||
| ------ | ------------ |
|
||||
| .tar | `tar` |
|
||||
| .tar.gz, .tgz | `tar` or `pigz` |
|
||||
| .tar.bz, .tar.bz2, .tbz, .tbz2 | `tar` or `pbzip2` |
|
||||
| .tar.xz, .txz | `tar` with xz support |
|
||||
| .tar.zma, .tlz | `tar` with lzma support |
|
||||
| .gz | `gunzip` or `pigz` |
|
||||
| .bz, .bz2 | `bunzip2` or `pbzip2` |
|
||||
| .xz | `unxz` |
|
||||
| .lzma | `unzlma` |
|
||||
| .Z | `uncompress` |
|
||||
| .zip | `unzip` |
|
||||
| .rar | `unrar` or `rar` |
|
||||
| .7z | `7za` |
|
|
@ -1,4 +0,0 @@
|
|||
#compdef unarchive
|
||||
|
||||
_arguments \
|
||||
"*:archive:_files -g '(#i)*.(tar|gz|tgz|bz|bz2|tbz|tbz2|xz|txz|tlz|lzma|Z|zip|rar|7z|001)(-.)'"
|
|
@ -1,34 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Creates archive files
|
||||
#
|
||||
|
||||
if (( # < 2 )); then
|
||||
print "usage: ${0} <archive_name.ext> <file>..." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
# we are quitting (above) if there are less than 2 vars,
|
||||
# so we don't need any argc check here.
|
||||
|
||||
local archive_name="${1}"
|
||||
shift
|
||||
|
||||
# pigz and pbzip2 are aliased in the init.zsh file. This provides a significant speedup, resulting in a
|
||||
# near-liner decrease in compression time based on on the number of available cores.
|
||||
|
||||
case "${archive_name}" in
|
||||
(*.tar.gz|*.tgz) tar -cvzf "${archive_name}" "${@}" ;;
|
||||
(*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar -cvjf "${archive_name}" "${@}" ;;
|
||||
(*.tar.xz|*.txz) tar -J --help &>/dev/null && tar -cvJf "${archive_name}" "${@}" ;;
|
||||
(*.tar.lzma|*.tlz) tar --lzma --help &>/dev/null && tar --lzma -cvf "${archive_name}" "${@}" ;;
|
||||
(*.tar) tar -cvf "${archive_name}" "${@}" ;;
|
||||
(*.zip) zip -r "${archive_name}" "${@}" ;;
|
||||
(*.rar) rar a "${archive_name}" "${@}" ;;
|
||||
(*.7z) 7za a "${archive_name}" "${@}" ;;
|
||||
(*.gz) print "${0}: .gz is only useful for single files, and does not capture permissions. Use .tar.gz" ;;
|
||||
(*.bz|*.bz2) print "${0}: .bzip2 is only useful for single files, and does not capture permissions. Use .tar.bz2" ;;
|
||||
(*.xz) print "${0}: .xz is only useful for single files, and does not capture permissions. Use .tar.xz" ;;
|
||||
(*.lzma) print "${0}: .lzma is only useful for single files, and does not capture permissions. Use .tar.lzma" ;;
|
||||
(*) print "${0}: unknown archive type: ${archive_name}" ;;
|
||||
esac
|
|
@ -1,41 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Unarchives files
|
||||
#
|
||||
|
||||
if (( # < 1 )); then
|
||||
print "usage: ${0} <archive_name.ext>..." >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
setopt LOCAL_OPTIONS ERR_RETURN
|
||||
|
||||
# using unpigz/pbunzip2 provides little to decompression time; the benefit is mainly in compression time.
|
||||
# setting it as an alias in the init.zsh file should be sufficient here.
|
||||
|
||||
while (( # > 0 )); do
|
||||
local archive_name="${1}"
|
||||
case "${archive_name}" in
|
||||
(*.tar.gz|*.tgz) tar -xvzf "${archive_name}" ;;
|
||||
(*.tar.bz|*.tar.bz2|*.tbz|*.tbz2) tar -xvjf "${archive_name}" ;;
|
||||
(*.tar.xz|*.txz) tar -J --help &>/dev/null && tar -xvJf "${archive_name}" \
|
||||
|| xzcat "${archive_name}" | tar xvf - ;;
|
||||
(*.tar.lzma|*.tlz) tar --lzma --help &>/dev/null && tar --lzma -xvf "${archive_name}" \
|
||||
|| lzcat "${archive_name}" | tar xvf - ;;
|
||||
(*.tar) tar xvf "${archive_name}" ;;
|
||||
(*.gz) gunzip "${archive_name}" ;;
|
||||
(*.bz|*.bz2) bunzip2 "${archive_name}" ;;
|
||||
(*.xz) unxz "${archive_name}" ;;
|
||||
(*.lzma) unlzma "${archive_name}" ;;
|
||||
(*.Z) uncompress "${archive_name}" ;;
|
||||
(*.zip) unzip "${archive_name}";;
|
||||
(*.rar) (( $+{commands[unrar]} )) && unrar x -ad "${archive_name}" \
|
||||
|| rar x -ad "${archive_name}" ;;
|
||||
(*.7z|*.001) 7za x "${archive_name}" ;;
|
||||
(*)
|
||||
print "${0}: unknown archive type: ${archive_name}"
|
||||
return 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
|
@ -1,17 +0,0 @@
|
|||
#
|
||||
# Archive aliases
|
||||
#
|
||||
|
||||
# if pigz/pbzip2 are available, alias them as they are drop-in replacements for gzip and bzip2, respectively.
|
||||
|
||||
#
|
||||
# pigz
|
||||
#
|
||||
(( ${+commands[pigz]} )) && alias gzip='pigz'
|
||||
(( ${+commands[unpigz]} )) && alias gunzip='unpigz'
|
||||
|
||||
#
|
||||
# pbzip2
|
||||
#
|
||||
(( ${+commands[pbzip2]} )) && alias bzip2='pbzip2'
|
||||
(( ${+commands[pbunzip2]} )) && alias bunzip2='pbunzip2'
|
|
@ -1,13 +0,0 @@
|
|||
zsh-autosuggestions
|
||||
===================
|
||||
|
||||
_[Fish](http://fishshell.com/)-like fast/unobtrusive autosuggestions for Zsh._
|
||||
|
||||
It suggests commands as you type, based on command history.
|
||||
|
||||
<a href="https://asciinema.org/a/37390" target="_blank"><img src="https://asciinema.org/a/37390.png" width="400" /></a>
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Contributions should be submitted [upstream to zsh-autosuggestions](https://github.com/zsh-users/zsh-autosuggestions)
|
|
@ -1 +0,0 @@
|
|||
Subproject commit a7f0106b31c2538a36cab30428e6ca65d9a2ae60
|
|
@ -1,9 +0,0 @@
|
|||
#
|
||||
# Fish-like fast/unobtrusive autosuggestions for zsh.
|
||||
#
|
||||
# It suggests commands as you type, based on command history.
|
||||
#
|
||||
|
||||
# source script
|
||||
source ${0:h}/external/zsh-autosuggestions.zsh || return 1
|
||||
|
|
@ -1,21 +0,0 @@
|
|||
completion
|
||||
==========
|
||||
|
||||
Enables and configures smart and extensive tab completion.
|
||||
|
||||
Completions are sourced from [zsh-completions][zsh-completions].
|
||||
|
||||
Zsh options
|
||||
-----------
|
||||
|
||||
* `ALWAYS_TO_END` moves cursor to end of word if a full completion is inserted.
|
||||
* `PATH_DIRS` performs path search even on command names with slashes in them.
|
||||
* `NO_CASE_GLOB` makes globbing case insensitive.
|
||||
* `NO_LIST_BEEP` doesn't beep on ambiguous completions.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Command completions should be submitted [upstream to zsh-completions][zsh-completions].
|
||||
|
||||
[zsh-completions]: https://github.com/zsh-users/zsh-completions
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 8ec8c8c5c662c3cb77231b7458ce1975d2f8c967
|
|
@ -1,96 +0,0 @@
|
|||
#
|
||||
# Completion enhancements
|
||||
#
|
||||
|
||||
|
||||
#
|
||||
# initialization
|
||||
#
|
||||
|
||||
# if it's a dumb terminal, return.
|
||||
if [[ ${TERM} == 'dumb' ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# add the completions to the fpath
|
||||
fpath=(${0:h}/external/src ${fpath})
|
||||
|
||||
# load and initialize the completion system
|
||||
autoload -Uz compinit && compinit -C -d "${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}"
|
||||
|
||||
|
||||
#
|
||||
# zsh options
|
||||
#
|
||||
|
||||
# If a completion is performed with the cursor within a word, and a full
|
||||
# completion is inserted, the cursor is moved to the end of the word.
|
||||
setopt ALWAYS_TO_END
|
||||
|
||||
# Perform a path search even on command names with slashes in them.
|
||||
setopt PATH_DIRS
|
||||
|
||||
# Make globbing (filename generation) not sensitive to case.
|
||||
setopt NO_CASE_GLOB
|
||||
|
||||
# Don't beep on an ambiguous completion.
|
||||
setopt NO_LIST_BEEP
|
||||
|
||||
|
||||
#
|
||||
# completion module options
|
||||
#
|
||||
|
||||
# group matches and describe.
|
||||
zstyle ':completion:*:*:*:*:*' menu select
|
||||
zstyle ':completion:*:matches' group yes
|
||||
zstyle ':completion:*:options' description yes
|
||||
zstyle ':completion:*:options' auto-description '%d'
|
||||
zstyle ':completion:*:corrections' format '%F{green}-- %d (errors: %e) --%f'
|
||||
zstyle ':completion:*:descriptions' format '%F{yellow}-- %d --%f'
|
||||
zstyle ':completion:*:messages' format '%F{purple}-- %d --%f'
|
||||
zstyle ':completion:*:warnings' format '%F{red}-- no matches found --%f'
|
||||
zstyle ':completion:*' format '%F{yellow}-- %d --%f'
|
||||
zstyle ':completion:*' group-name ''
|
||||
zstyle ':completion:*' verbose yes
|
||||
zstyle ':completion:*' matcher-list 'm:{a-zA-Z}={A-Za-z}' '+r:|?=**'
|
||||
|
||||
# directories
|
||||
if (( ! ${+LS_COLORS} )); then
|
||||
# Locally use same LS_COLORS definition from utility module, in case it was not set
|
||||
local LS_COLORS='di=1;34:ln=35:so=32:pi=33:ex=31:bd=1;36:cd=1;33:su=30;41:sg=30;46:tw=30;42:ow=30;43'
|
||||
fi
|
||||
zstyle ':completion:*:default' list-colors ${(s.:.)LS_COLORS}
|
||||
zstyle ':completion:*:*:cd:*' tag-order local-directories directory-stack path-directories
|
||||
zstyle ':completion:*:*:cd:*:directory-stack' menu yes select
|
||||
zstyle ':completion:*:-tilde-:*' group-order 'named-directories' 'path-directories' 'expand'
|
||||
zstyle ':completion:*' squeeze-slashes true
|
||||
|
||||
# enable caching
|
||||
zstyle ':completion::complete:*' use-cache on
|
||||
zstyle ':completion::complete:*' cache-path "${ZDOTDIR:-${HOME}}/.zcompcache"
|
||||
|
||||
# ignore useless commands and functions
|
||||
zstyle ':completion:*:functions' ignored-patterns '(_*|pre(cmd|exec)|prompt_*)'
|
||||
|
||||
# completion sorting
|
||||
zstyle ':completion:*:*:-subscript-:*' tag-order indexes parameters
|
||||
|
||||
# Man
|
||||
zstyle ':completion:*:manuals' separate-sections true
|
||||
zstyle ':completion:*:manuals.(^1*)' insert-sections true
|
||||
|
||||
# history
|
||||
zstyle ':completion:*:history-words' stop yes
|
||||
zstyle ':completion:*:history-words' remove-all-dups yes
|
||||
zstyle ':completion:*:history-words' list false
|
||||
zstyle ':completion:*:history-words' menu yes
|
||||
|
||||
# ignore multiple entries.
|
||||
zstyle ':completion:*:(rm|kill|diff):*' ignore-line other
|
||||
zstyle ':completion:*:rm:*' file-patterns '*:all-files'
|
||||
|
||||
# If the _my_hosts function is defined, it will be called to add the ssh hosts
|
||||
# completion, otherwise _ssh_hosts will fall through and read the ~/.ssh/config
|
||||
zstyle -e ':completion:*:*:ssh:*:my-accounts' users-hosts \
|
||||
'[[ -f ${HOME}/.ssh/config && ${key} == hosts ]] && key=my_hosts reply=()'
|
|
@ -1,19 +0,0 @@
|
|||
custom
|
||||
======
|
||||
|
||||
Add any custom aliases/settings to the `init.zsh` file.
|
||||
|
||||
Any functions should go in the `functions` subdirectory, where the name of the
|
||||
file is the name of the function.
|
||||
|
||||
For example, this function from your `.zshrc`:
|
||||
```zsh
|
||||
foo() {
|
||||
print 'bar'
|
||||
}
|
||||
```
|
||||
|
||||
becomes a file named `foo` in the `functions` subdirectory containing:
|
||||
```zsh
|
||||
print 'bar'
|
||||
```
|
|
@ -1,4 +0,0 @@
|
|||
# this is an example function
|
||||
# running 'example_function' in a zsh session will execute the code below
|
||||
|
||||
print "executed example function: ${ZIM_HOME}/modules/custom/functions/example_function!"
|
|
@ -1,8 +0,0 @@
|
|||
#
|
||||
# Custom aliases/settings
|
||||
#
|
||||
|
||||
# any custom stuff should go here.
|
||||
# ensure that 'custom' exists in the zmodules array in your .zimrc
|
||||
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
debug
|
||||
=====
|
||||
|
||||
Provides a function to debug Zim.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
* `trace-zim` provides a trace of Zsh/Zim startup
|
||||
|
||||
Notes
|
||||
-----
|
||||
|
||||
`trace-zim` will not alter your current dotfiles. It will copy your environment
|
||||
to a temporary directory, launch Zsh within that environment, and output logs.
|
||||
|
||||
This will provide a `ztrace.tar.gz` archive, which should be attached to any bug
|
||||
reports if you need help with an issue that you don't understand.
|
|
@ -1,105 +0,0 @@
|
|||
#!/usr/bin/env zsh
|
||||
#
|
||||
# Generates trace log to debug zim and zsh issues
|
||||
#
|
||||
|
||||
print "This function creates a trace log to debug
|
||||
Zsh and Zim functionality.
|
||||
|
||||
It will copy your .zshrc to /tmp/ztrace/, ammend profiling
|
||||
code, launch a new shell, log the trace, close the shell,
|
||||
archive the logs, and finally print the path to the archive."
|
||||
|
||||
read \?"Press [Enter] to begin trace."
|
||||
|
||||
mkdir -p /tmp/ztrace
|
||||
# make sure that we were able to create the directory
|
||||
if [[ ! -d /tmp/ztrace ]]; then
|
||||
print 'failed to create /tmp/ztrace directory. Aborting.'
|
||||
return 1
|
||||
else
|
||||
# check if known output file, if exists
|
||||
# rm all directory contents
|
||||
if [[ -e /tmp/ztrace/ztrace.log ]]; then
|
||||
print "\nLogs from previous run of trace-zim are present
|
||||
Deleting old logs now..."
|
||||
# use of anonymous function for dotglob opt
|
||||
() {
|
||||
setopt dotglob
|
||||
rm -rf /tmp/ztrace/*
|
||||
}
|
||||
fi
|
||||
fi
|
||||
|
||||
# get some basic system information (kernel and zsh version)
|
||||
print "Zsh version:
|
||||
$(zsh --version)
|
||||
Kernel information:
|
||||
$(uname -a)
|
||||
fpath info:
|
||||
${fpath}" >! /tmp/ztrace/sysinfo
|
||||
|
||||
cp ${ZDOTDIR:-${HOME}}/.zshrc /tmp/ztrace/.zshrc.orig
|
||||
cp ${ZDOTDIR:-${HOME}}/.zimrc /tmp/ztrace/.zimrc
|
||||
# rsync will allow us to not have to copy the .git folder; use if available
|
||||
if (( ${+commands[rsync]} )); then
|
||||
rsync -az --exclude .git ${ZIM_HOME} /tmp/ztrace/
|
||||
else
|
||||
cp -R ${ZIM_HOME} /tmp/ztrace/
|
||||
fi
|
||||
|
||||
# create a modified .zshrc to produce a trace log
|
||||
cat <<EOF >! /tmp/ztrace/.zshrc
|
||||
###################
|
||||
# zim trace start #
|
||||
###################
|
||||
PS4=$'%D{%s%6.}-_-'
|
||||
exec 3>&2 2>/tmp/ztrace/sample-time.$$.log
|
||||
zmodload zsh/zprof
|
||||
setopt xtrace prompt_subst
|
||||
EOF
|
||||
|
||||
cat /tmp/ztrace/.zshrc.orig >>! /tmp/ztrace/.zshrc
|
||||
|
||||
cat <<EOF >>! /tmp/ztrace/.zshrc
|
||||
#################
|
||||
# zim trace end #
|
||||
#################
|
||||
|
||||
unsetopt xtrace
|
||||
zprof >! /tmp/ztrace/zprof
|
||||
#non-linux systems have weird fd; also, no real need to redirect back
|
||||
#prompt is (practically speaking) non-interactive, fd exists only for that process
|
||||
#which is closed (by typing exit)
|
||||
|
||||
#exec 2>&3 3>&-
|
||||
EOF
|
||||
|
||||
print "\nSpawning zsh and producing trace...\n\n"
|
||||
ZDOTDIR=/tmp/ztrace zsh -ic 'exit'
|
||||
print "Trace complete.
|
||||
Parsing logs to a nicer format; this may take some time..."
|
||||
|
||||
# this is ugly thing makes it pretty...
|
||||
while read line; do if [[ ${line} =~ '^[0-9]+-_-' ]]; then crt=000000$((${line%%-_-*}-10#0$last)); printf "%12.9f %s\n" ${crt:0:${#crt}-6}.${crt:${#crt}-6} ${line#*-_-}; last=${line%%-_-*}; fi; done < /tmp/ztrace/sample-time.(*).log > /tmp/ztrace/ztrace.log
|
||||
print "Parsing complete!"
|
||||
|
||||
# safe to remove old, unneeded environment files
|
||||
print "Tidying up before archive..."
|
||||
rm -f /tmp/ztrace/sample-time.*
|
||||
rm -rf /tmp/ztrace/.zim
|
||||
rm -f /tmp/ztrace/.zshrc
|
||||
mv /tmp/ztrace/.zshrc.orig /tmp/ztrace/.zshrc
|
||||
rm -f /tmp/ztrace/.zhistory
|
||||
rm -f /tmp/ztrace/.zcompdump*
|
||||
|
||||
print "Archiving trace logs...\n"
|
||||
|
||||
tar -czf /tmp/ztrace.tar.gz /tmp/ztrace/
|
||||
|
||||
print "Archive complete!\n
|
||||
Trace by with execution time available at:
|
||||
/tmp/ztrace/ztrace.log
|
||||
Archive (for sharing/help) available at:
|
||||
/tmp/ztrace.tar.gz"
|
||||
|
|
@ -1,16 +0,0 @@
|
|||
directory
|
||||
=========
|
||||
|
||||
Sets directory, navigation, and redirect options.
|
||||
|
||||
Zsh options
|
||||
-----------
|
||||
|
||||
* `AUTO_CD` performs cd to a directory if the typed command is invalid, but is a directory.
|
||||
* `AUTO_PUSHD` makes cd push the old directory to the directory stack.
|
||||
* `PUSHD_IGNORE_DUPS` does not push multiple copies of the same directory to the stack.
|
||||
* `PUSHD_SILENT` does not print the directory stack after pushd or popd.
|
||||
* `PUSHD_TO_HOME` has pushd without arguments act like `pushd ${HOME}`.
|
||||
* `EXTENDED_GLOB` treats `#`, `~`, and `^` as patterns for filename globbing.
|
||||
* `MULTIOS` performs implicit tees or cats when using multiple redirections.
|
||||
* `NO_CLOBBER` disallows `>` to overwrite existing files. Use `>|` or `>!` instead.
|
|
@ -1,38 +0,0 @@
|
|||
#
|
||||
# Directory navigation options
|
||||
#
|
||||
|
||||
#
|
||||
# Navigation
|
||||
#
|
||||
|
||||
# If a command is issued that can’t be executed as a normal command,
|
||||
# and the command is the name of a directory, perform the cd command to that directory.
|
||||
setopt AUTO_CD
|
||||
|
||||
# Make cd push the old directory onto the directory stack.
|
||||
setopt AUTO_PUSHD
|
||||
|
||||
# Don’t push multiple copies of the same directory onto the directory stack.
|
||||
setopt PUSHD_IGNORE_DUPS
|
||||
|
||||
# Do not print the directory stack after pushd or popd.
|
||||
setopt PUSHD_SILENT
|
||||
|
||||
# Have pushd with no arguments act like ‘pushd ${HOME}’.
|
||||
setopt PUSHD_TO_HOME
|
||||
|
||||
#
|
||||
# Globbing and fds
|
||||
#
|
||||
|
||||
# Treat the ‘#’, ‘~’ and ‘^’ characters as part of patterns for filename generation, etc.
|
||||
# (An initial unquoted ‘~’ always produces named directory expansion.)
|
||||
setopt EXTENDED_GLOB
|
||||
|
||||
# Perform implicit tees or cats when multiple redirections are attempted.
|
||||
setopt MULTIOS
|
||||
|
||||
# Disallow ‘>’ redirection to overwrite existing files.
|
||||
# ‘>|’ or ‘>!’ must be used to overwrite a file.
|
||||
setopt NO_CLOBBER
|
|
@ -1,19 +0,0 @@
|
|||
environment
|
||||
===========
|
||||
|
||||
Sets generic Zsh built-in environment options.
|
||||
|
||||
Also enables smart URL-pasting. This prevents the user from having to manually escape URLs.
|
||||
|
||||
Uses `.zimrc` defined `${ztermtitle}` variable to set the terminal title, if defined.
|
||||
|
||||
Zsh options
|
||||
-----------
|
||||
|
||||
* `AUTO_RESUME` resumes an existing job before creating a new one.
|
||||
* `INTERACTIVE_COMMENTS` allows comments starting with `#` in the shell.
|
||||
* `LONG_LIST_JOBS` lists jobs in verbose format by default.
|
||||
* `NOTIFY` reports job status immediately instead of waiting for the prompt.
|
||||
* `NO_BG_NICE` prevents background jobs being given a lower priority.
|
||||
* `NO_CHECK_JOBS` prevents status report of jobs on shell exit.
|
||||
* `NO_HUP` prevents SIGHUP to jobs on shell exit.
|
|
@ -1,52 +0,0 @@
|
|||
#
|
||||
# generic options and environment settings
|
||||
#
|
||||
|
||||
# Use smart URL pasting and escaping.
|
||||
autoload -Uz bracketed-paste-url-magic && zle -N bracketed-paste bracketed-paste-url-magic
|
||||
autoload -Uz url-quote-magic && zle -N self-insert url-quote-magic
|
||||
|
||||
# Treat single word simple commands without redirection as candidates for resumption of an existing job.
|
||||
setopt AUTO_RESUME
|
||||
|
||||
# Allow comments starting with `#` even in interactive shells.
|
||||
setopt INTERACTIVE_COMMENTS
|
||||
|
||||
# List jobs in the long format by default.
|
||||
setopt LONG_LIST_JOBS
|
||||
|
||||
# Report the status of background jobs immediately, rather than waiting until just before printing a prompt.
|
||||
setopt NOTIFY
|
||||
|
||||
# Prevent runing all background jobs at a lower priority.
|
||||
setopt NO_BG_NICE
|
||||
|
||||
# Prevent reporting the status of background and suspended jobs before exiting a shell with job control.
|
||||
# NO_CHECK_JOBS is best used only in combination with NO_HUP, else such jobs will be killed automatically.
|
||||
setopt NO_CHECK_JOBS
|
||||
|
||||
# Prevent sending the HUP signal to running jobs when the shell exits.
|
||||
setopt NO_HUP
|
||||
|
||||
# Remove path separtor from WORDCHARS.
|
||||
WORDCHARS=${WORDCHARS//[\/]}
|
||||
|
||||
# Set less or more as the default pager.
|
||||
if (( ! ${+PAGER} )); then
|
||||
if (( ${+commands[less]} )); then
|
||||
export PAGER=less
|
||||
else
|
||||
export PAGER=more
|
||||
fi
|
||||
fi
|
||||
|
||||
# sets the window title and updates upon directory change
|
||||
# more work probably needs to be done here to support multiplexers
|
||||
if (( ${+ztermtitle} )); then
|
||||
case ${TERM} in
|
||||
xterm*|*rxvt)
|
||||
precmd() { print -Pn "\e]0;${ztermtitle}\a" }
|
||||
precmd # we execute it once to initialize the window title
|
||||
;;
|
||||
esac
|
||||
fi
|
|
@ -1,14 +0,0 @@
|
|||
fasd
|
||||
====
|
||||
|
||||
[Fasd](https://github.com/clvv/fasd) (pronounced similar to "fast") is a command-line productivity booster.
|
||||
Fasd offers quick access to files and directories for POSIX shells. It is
|
||||
inspired by tools like [autojump](https://github.com/joelthelion/autojump),
|
||||
[z](http://github.com/rupa/z) and [v](https://github.com/rupa/v). Fasd keeps
|
||||
track of files and directories you have accessed, so that you can quickly
|
||||
reference them in the command line.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Contributions should be submitted [upstream to fasd](https://github.com/clvv/fasd).
|
|
@ -1,424 +0,0 @@
|
|||
# Fasd is originally written based on code from z (https://github.com/rupa/z)
|
||||
# by rupa deadwyler under the WTFPL license. Most if not all of the code has
|
||||
# been rewritten.
|
||||
|
||||
# Copyright (C) 2011, 2012 by Wei Dai. All rights reserved.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining
|
||||
# a copy of this software and associated documentation files (the
|
||||
# "Software"), to deal in the Software without restriction, including
|
||||
# without limitation the rights to use, copy, modify, merge, publish,
|
||||
# distribute, sublicense, and/or sell copies of the Software, and to
|
||||
# permit persons to whom the Software is furnished to do so, subject to
|
||||
# the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
# make zsh do word splitting inside this function
|
||||
[ "$ZSH_VERSION" ] && emulate sh && setopt localoptions
|
||||
|
||||
case $1 in
|
||||
--init) shift
|
||||
while [ "$1" ]; do
|
||||
case $1 in
|
||||
env)
|
||||
{ # Load configuration files
|
||||
|
||||
if [[ -s ${XDG_CONFIG_HOME:-"${HOME}/.config"}/fasd/config ]]; then
|
||||
source ${XDG_CONFIG_HOME:-"${HOME}/.config"}/fasd/config
|
||||
else
|
||||
[[ -s /etc/fasdrc ]] && source /etc/fasd
|
||||
[[ -s ${HOME}/.fasdrc ]] && source ${HOME}/.fasdrc
|
||||
fi
|
||||
|
||||
# set default options
|
||||
(( ! ${+_FASD_DATA} )) && _FASD_DATA="$HOME/.fasd"
|
||||
(( ! ${+_FASD_BLACKLIST} )) && _FASD_BLACKLIST="--help"
|
||||
(( ! ${+_FASD_SHIFT} )) && _FASD_SHIFT="sudo busybox"
|
||||
(( ! ${+_FASD_IGNORE} )) && _FASD_IGNORE="fasd ls echo"
|
||||
(( ! ${+_FASD_SINK} )) && _FASD_SINK=/dev/null
|
||||
(( ! ${+_FASD_TRACK_PWD} )) && _FASD_TRACK_PWD=1
|
||||
(( ! ${+_FASD_MAX} )) && _FASD_MAX=2000
|
||||
(( ! ${+_FASD_BACKENDS} )) && _FASD_BACKENDS=native
|
||||
(( ! ${+_FASD_FUZZY} )) && _FASD_FUZZY=2
|
||||
(( ! ${+_FASD_VIMINFO} )) && _FASD_VIMINFO="$HOME/.viminfo"
|
||||
(( ! ${+_FASD_RECENTLY_USED_XBEL} )) && \
|
||||
_FASD_RECENTLY_USED_XBEL="$HOME/.local/share/recently-used.xbel"
|
||||
|
||||
if (( ! ${+_FASD_AWK} )); then
|
||||
# awk preferences
|
||||
local awk; for awk in mawk gawk original-awk nawk awk; do
|
||||
$awk "" && _FASD_AWK=$awk && break
|
||||
done
|
||||
fi
|
||||
} >> ${_FASD_SINK:-/dev/null} 2>&1
|
||||
;;
|
||||
esac; shift
|
||||
done
|
||||
;;
|
||||
|
||||
# if "$_fasd_cur" or "$2" is a query, then output shell code to be eval'd
|
||||
--word-complete-trigger)
|
||||
shift; [ "$2" ] && local _fasd_cur="$2" || return
|
||||
case $_fasd_cur in
|
||||
,*) printf %s\\n "$1 e $_fasd_cur";;
|
||||
f,*) printf %s\\n "$1 f ${_fasd_cur#?}";;
|
||||
d,*) printf %s\\n "$1 d ${_fasd_cur#?}";;
|
||||
*,,) printf %s\\n "$1 e $_fasd_cur";;
|
||||
*,,f) printf %s\\n "$1 f ${_fasd_cur%?}";;
|
||||
*,,d) printf %s\\n "$1 d ${_fasd_cur%?}";;
|
||||
esac
|
||||
;;
|
||||
|
||||
--sanitize) shift; printf %s\\n "$*" | \
|
||||
sed 's/\([^\]\)$( *[^ ]* *\([^)]*\)))*/\1\2/g
|
||||
s/\([^\]\)[|&;<>$`{}]\{1,\}/\1 /g'
|
||||
;;
|
||||
|
||||
--proc) shift # process commands
|
||||
# stop if we don't own $_FASD_DATA or $_FASD_RO is set
|
||||
[ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return
|
||||
|
||||
# blacklists
|
||||
local each; for each in $_FASD_BLACKLIST; do
|
||||
case " $* " in *\ $each\ *) return;; esac
|
||||
done
|
||||
|
||||
# shifts
|
||||
while true; do
|
||||
case " $_FASD_SHIFT " in
|
||||
*\ $1\ *) shift;;
|
||||
*) break;;
|
||||
esac
|
||||
done
|
||||
|
||||
# ignores
|
||||
case " $_FASD_IGNORE " in
|
||||
*\ $1\ *) return;;
|
||||
esac
|
||||
|
||||
shift; fasd --add "$@" # add all arguments except command
|
||||
;;
|
||||
|
||||
--add|-A) shift # add entries
|
||||
# stop if we don't own $_FASD_DATA or $_FASD_RO is set
|
||||
[ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return
|
||||
|
||||
# find all valid path arguments, convert them to simplest absolute form
|
||||
local paths="$(while [ "$1" ]; do
|
||||
[ -e "$1" ] && printf %s\\n "$1"; shift
|
||||
done | sed '/^[^/]/s@^@'"$PWD"'/@
|
||||
s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0
|
||||
s@[^/][^/]*//*\.\./@/@;t 0
|
||||
s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@;s@^$@/@' 2>> "$_FASD_SINK" \
|
||||
| tr '\n' '|')"
|
||||
|
||||
# add current pwd if the option is set
|
||||
[ "$_FASD_TRACK_PWD" = "1" -a "$PWD" != "$HOME" ] && paths="$paths|$PWD"
|
||||
|
||||
[ -z "${paths##\|}" ] && return # stop if we have nothing to add
|
||||
|
||||
# maintain the file
|
||||
local tempfile
|
||||
tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return
|
||||
$_FASD_AWK -v list="$paths" -v now="$(date +%s)" -v max="$_FASD_MAX" -F"|" '
|
||||
BEGIN {
|
||||
split(list, files, "|")
|
||||
for(i in files) {
|
||||
path = files[i]
|
||||
if(path == "") continue
|
||||
paths[path] = path # array for checking
|
||||
rank[path] = 1
|
||||
time[path] = now
|
||||
}
|
||||
}
|
||||
$2 >= 1 {
|
||||
if($1 in paths) {
|
||||
rank[$1] = $2 + 1 / $2
|
||||
time[$1] = now
|
||||
} else {
|
||||
rank[$1] = $2
|
||||
time[$1] = $3
|
||||
}
|
||||
count += $2
|
||||
}
|
||||
END {
|
||||
if(count > max)
|
||||
for(i in rank) print i "|" 0.9*rank[i] "|" time[i] # aging
|
||||
else
|
||||
for(i in rank) print i "|" rank[i] "|" time[i]
|
||||
}' "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile"
|
||||
if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then
|
||||
env rm -f "$tempfile"
|
||||
else
|
||||
env mv -f "$tempfile" "$_FASD_DATA"
|
||||
fi
|
||||
;;
|
||||
|
||||
--delete|-D) shift # delete entries
|
||||
# stop if we don't own $_FASD_DATA or $_FASD_RO is set
|
||||
[ -f "$_FASD_DATA" -a ! -O "$_FASD_DATA" ] || [ "$_FASD_RO" ] && return
|
||||
|
||||
# turn valid arguments into entry-deleting sed commands
|
||||
local sed_cmd="$(while [ "$1" ]; do printf %s\\n "$1"; shift; done | \
|
||||
sed '/^[^/]/s@^@'"$PWD"'/@;s@/\.\.$@/../@;s@/\(\./\)\{1,\}@/@g;:0
|
||||
s@[^/][^/]*//*\.\./@/@;t 0
|
||||
s@^/*\.\./@/@;s@//*@/@g;s@/\.\{0,1\}$@@
|
||||
s@^$@/@;s@\([.[\/*^$]\)@\\\1@g;s@^\(.*\)$@/^\1|/d@' 2>> "$_FASD_SINK")"
|
||||
|
||||
# maintain the file
|
||||
local tempfile
|
||||
tempfile="$(mktemp "$_FASD_DATA".XXXXXX)" || return
|
||||
|
||||
sed "$sed_cmd" "$_FASD_DATA" 2>> "$_FASD_SINK" >| "$tempfile"
|
||||
|
||||
if [ $? -ne 0 -a -f "$_FASD_DATA" ]; then
|
||||
env rm -f "$tempfile"
|
||||
else
|
||||
env mv -f "$tempfile" "$_FASD_DATA"
|
||||
fi
|
||||
;;
|
||||
|
||||
--query) shift # query the db, --query [$typ ["$fnd" [$mode]]]
|
||||
[ -f "$_FASD_DATA" ] || return # no db yet
|
||||
[ "$1" ] && local typ="$1"
|
||||
[ "$2" ] && local fnd="$2"
|
||||
[ "$3" ] && local mode="$3"
|
||||
|
||||
# cat all backends
|
||||
local each _fasd_data; for each in $_FASD_BACKENDS; do
|
||||
_fasd_data="$_fasd_data
|
||||
$(fasd --backend $each)"
|
||||
done
|
||||
[ "$_fasd_data" ] || _fasd_data="$(cat "$_FASD_DATA")"
|
||||
|
||||
# set mode specific code for calculating the prior
|
||||
case $mode in
|
||||
rank) local prior='times[i]';;
|
||||
recent) local prior='sqrt(100000/(1+t-la[i]))';;
|
||||
*) local prior='times[i] * frecent(la[i])';;
|
||||
esac
|
||||
|
||||
if [ "$fnd" ]; then # dafault matching
|
||||
local bre="$(printf %s\\n "$fnd" | sed 's/\([*\.\\\[]\)/\\\1/g
|
||||
s@ @[^|]*@g;s/\$$/|/')"
|
||||
bre='^[^|]*'"$bre"'[^|/]*|'
|
||||
local _ret="$(printf %s\\n "$_fasd_data" | grep "$bre")"
|
||||
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
|
||||
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
|
||||
done)"
|
||||
if [ "$_ret" ]; then
|
||||
_fasd_data="$_ret"
|
||||
else # no case mathcing
|
||||
_ret="$(printf %s\\n "$_fasd_data" | grep -i "$bre")"
|
||||
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
|
||||
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
|
||||
done)"
|
||||
if [ "$_ret" ]; then
|
||||
_fasd_data="$_ret"
|
||||
elif [ "${_FASD_FUZZY:-0}" -gt 0 ]; then # fuzzy matching
|
||||
local fuzzy_bre="$(printf %s\\n "$fnd" | \
|
||||
sed 's/\([*\.\\\[]\)/\\\1/g;s/\$$/|/
|
||||
s@\(\\\{0,1\}[^ ]\)@\1[^|/]\\{0,'"$_FASD_FUZZY"'\\}@g
|
||||
s@ @[^|]*@g')"
|
||||
fuzzy_bre='^[^|]*'"$fuzzy_bre"'[^|/]*|'
|
||||
_ret="$(printf %s\\n "$_fasd_data" | grep -i "$fuzzy_bre")"
|
||||
[ "$_ret" ] && _ret="$(printf %s\\n "$_ret" | while read -r line; do
|
||||
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
|
||||
done)"
|
||||
[ "$_ret" ] && _fasd_data="$_ret" || _fasd_data=
|
||||
fi
|
||||
fi
|
||||
else # no query arugments
|
||||
_fasd_data="$(printf %s\\n "$_fasd_data" | while read -r line; do
|
||||
[ -${typ:-e} "${line%%\|*}" ] && printf %s\\n "$line"
|
||||
done)"
|
||||
fi
|
||||
|
||||
# query the database
|
||||
[ "$_fasd_data" ] && printf %s\\n "$_fasd_data" | \
|
||||
$_FASD_AWK -v t="$(date +%s)" -F"|" '
|
||||
function frecent(time) {
|
||||
dx = t-time
|
||||
if( dx < 3600 ) return 6
|
||||
if( dx < 86400 ) return 4
|
||||
if( dx < 604800 ) return 2
|
||||
return 1
|
||||
}
|
||||
{
|
||||
if(!paths[$1]) {
|
||||
times[$1] = $2
|
||||
la[$1] = $3
|
||||
paths[$1] = 1
|
||||
} else {
|
||||
times[$1] += $2
|
||||
if($3 > la[$1]) la[$1] = $3
|
||||
}
|
||||
}
|
||||
END {
|
||||
for(i in paths) printf "%-10s %s\n", '"$prior"', i
|
||||
}' - 2>> "$_FASD_SINK"
|
||||
;;
|
||||
|
||||
--backend)
|
||||
case $2 in
|
||||
native) cat "$_FASD_DATA";;
|
||||
viminfo)
|
||||
< "$_FASD_VIMINFO" sed -n '/^>/{s@~@'"$HOME"'@
|
||||
s/^..//
|
||||
p
|
||||
}' | $_FASD_AWK -v t="$(date +%s)" '{
|
||||
t -= 60
|
||||
print $0 "|1|" t
|
||||
}'
|
||||
;;
|
||||
recently-used)
|
||||
local nl="$(printf '\\\nX')"; nl="${nl%X}" # slash newline for sed
|
||||
tr -d '\n' < "$_FASD_RECENTLY_USED_XBEL" | \
|
||||
sed 's@file:/@'"$nl"'@g;s@count="@'"$nl"'@g' | sed '1d;s/".*$//' | \
|
||||
tr '\n' '|' | sed 's@|/@'"$nl"'@g' | $_FASD_AWK -F'|' '{
|
||||
sum = 0
|
||||
for( i=2; i<=NF; i++ ) sum += $i
|
||||
print $1 "|" sum
|
||||
}'
|
||||
;;
|
||||
current)
|
||||
for path in *; do
|
||||
printf "$PWD/%s|1\\n" "$path"
|
||||
done
|
||||
;;
|
||||
spotlight)
|
||||
mdfind '(kMDItemFSContentChangeDate >= $time.today) ||
|
||||
kMDItemLastUsedDate >= $time.this_month' \
|
||||
| sed '/Library\//d
|
||||
/\.app$/d
|
||||
s/$/|2/'
|
||||
;;
|
||||
*) eval "$2";;
|
||||
esac
|
||||
;;
|
||||
|
||||
*) # parsing logic and processing
|
||||
local fnd= last= _FASD_BACKENDS="$_FASD_BACKENDS" _fasd_data= comp= exec=
|
||||
while [ "$1" ]; do case $1 in
|
||||
--complete) [ "$2" = "--" ] && shift; set -- $2; local lst=1 r=r comp=1;;
|
||||
--query|--add|--delete|-A|-D) fasd "$@"; return $?;;
|
||||
--version) [ -z "$comp" ] && echo "1.0.1" && return;;
|
||||
--) while [ "$2" ]; do shift; fnd="$fnd $1"; last="$1"; done;;
|
||||
-*) local o="${1#-}"; while [ "$o" ]; do case $o in
|
||||
s*) local show=1;;
|
||||
l*) local lst=1;;
|
||||
i*) [ -z "$comp" ] && local interactive=1 show=1;;
|
||||
r*) local mode=rank;;
|
||||
t*) local mode=recent;;
|
||||
e*) o="${o#?}"; if [ "$o" ]; then # there are characters after "-e"
|
||||
local exec="$o" # anything after "-e"
|
||||
else # use the next argument
|
||||
local exec="${2:?"-e: Argument needed "}"
|
||||
shift
|
||||
fi; break;;
|
||||
b*) o="${o#?}"; if [ "$o" ]; then
|
||||
_FASD_BACKENDS="$o"
|
||||
else
|
||||
_FASD_BACKENDS="${2:?"-b: Argument needed"}"
|
||||
shift
|
||||
fi; break;;
|
||||
B*) o="${o#?}"; if [ "$o" ]; then
|
||||
_FASD_BACKENDS="$_FASD_BACKENDS $o"
|
||||
else
|
||||
_FASD_BACKENDS="$_FASD_BACKENDS ${2:?"-B: Argument needed"}"
|
||||
shift
|
||||
fi; break;;
|
||||
a*) local typ=e;;
|
||||
d*) local typ=d;;
|
||||
f*) local typ=f;;
|
||||
R*) local r=r;;
|
||||
[0-9]*) local _fasd_i="$o"; break;;
|
||||
h*) [ -z "$comp" ] && echo "fasd [options] [query ...]
|
||||
[f|a|s|d|z] [options] [query ...]
|
||||
options:
|
||||
-s list paths with scores
|
||||
-l list paths without scores
|
||||
-i interactive mode
|
||||
-e <cmd> set command to execute on the result file
|
||||
-b <name> only use <name> backend
|
||||
-B <name> add additional backend <name>
|
||||
-a match files and directories
|
||||
-d match directories only
|
||||
-f match files only
|
||||
-r match by rank only
|
||||
-t match by recent access only
|
||||
-R reverse listing order
|
||||
-h show a brief help message
|
||||
-[0-9] select the nth entry
|
||||
|
||||
fasd [-A|-D] [paths ...]
|
||||
-A add paths
|
||||
-D delete paths" >&2 && return;;
|
||||
esac; o="${o#?}"; done;;
|
||||
*) fnd="$fnd $1"; last="$1";;
|
||||
esac; shift; done
|
||||
|
||||
# guess whether the last query is selected from tab completion
|
||||
case $last in
|
||||
/?*) if [ -z "$show$lst" -a -${typ:-e} "$last" -a "$exec" ]; then
|
||||
$exec "$last"
|
||||
return
|
||||
fi;;
|
||||
esac
|
||||
|
||||
local R; [ -z "$r" ] && R=r || R= # let $R be the opposite of $r
|
||||
fnd="${fnd# }"
|
||||
|
||||
local res
|
||||
res="$(fasd --query 2>> "$_FASD_SINK")" # query the database
|
||||
[ $? -gt 0 ] && return
|
||||
if [ 0 -lt ${_fasd_i:-0} ] 2>> "$_FASD_SINK"; then
|
||||
res="$(printf %s\\n "$res" | sort -n${R} | \
|
||||
sed -n "$_fasd_i"'s/^[^ ]*[ ]*//p')"
|
||||
elif [ "$interactive" ] || [ "$exec" -a -z "$fnd$lst$show" -a -t 1 ]; then
|
||||
if [ "$(printf %s "$res" | sed -n '$=')" -gt 1 ]; then
|
||||
res="$(printf %s\\n "$res" | sort -n${R})"
|
||||
printf %s\\n "$res" | sed = | sed 'N;s/\n/ /' | sort -nr >&2
|
||||
printf "> " >&2
|
||||
local i; read i; [ 0 -lt "${i:-0}" ] 2>> "$_FASD_SINK" || return 1
|
||||
fi
|
||||
res="$(printf %s\\n "$res" | sed -n "${i:-1}"'s/^[^ ]*[ ]*//p')"
|
||||
elif [ "$lst" ]; then
|
||||
[ "$res" ] && printf %s\\n "$res" | sort -n${r} | sed 's/^[^ ]*[ ]*//'
|
||||
return
|
||||
elif [ "$show" ]; then
|
||||
[ "$res" ] && printf %s\\n "$res" | sort -n${r}
|
||||
return
|
||||
elif [ "$fnd" ] && [ "$exec" -o ! -t 1 ]; then # exec or subshell
|
||||
res="$(printf %s\\n "$res" | sort -n | sed -n '$s/^[^ ]*[ ]*//p')"
|
||||
else # no args, show
|
||||
[ "$res" ] && printf %s\\n "$res" | sort -n${r}
|
||||
return
|
||||
fi
|
||||
if [ "$res" ]; then
|
||||
fasd --add "$res"
|
||||
[ -z "$exec" ] && exec='printf %s\n'
|
||||
$exec "$res"
|
||||
fi
|
||||
;;
|
||||
esac
|
||||
|
||||
#case $- in
|
||||
# *i*) ;; # assume being sourced, do nothing
|
||||
# *) # assume being executed as an executable
|
||||
# if [ -x "$_FASD_SHELL" -a -z "$_FASD_SET" ]; then
|
||||
# _FASD_SET=1 exec $_FASD_SHELL "$0" "$@"
|
||||
# else
|
||||
# fasd "$@"
|
||||
# fi;;
|
||||
#esac
|
|
@ -1,88 +0,0 @@
|
|||
fasd --init env
|
||||
|
||||
# function to execute built-in cd
|
||||
fasd_cd() {
|
||||
if [ $# -le 1 ]; then
|
||||
fasd "$@"
|
||||
else
|
||||
local _fasd_ret="$(fasd -e 'printf %s' "$@")"
|
||||
[ -z "$_fasd_ret" ] && return
|
||||
[ -d "$_fasd_ret" ] && cd "$_fasd_ret" || printf %s\n "$_fasd_ret"
|
||||
fi
|
||||
}
|
||||
|
||||
alias a='fasd -a'
|
||||
alias s='fasd -si'
|
||||
alias sd='fasd -sid'
|
||||
alias sf='fasd -sif'
|
||||
alias d='fasd -d'
|
||||
alias f='fasd -f'
|
||||
alias v='f -e vim -b viminfo'
|
||||
alias z='fasd_cd -d'
|
||||
alias zz='fasd_cd -d -i'
|
||||
|
||||
# add zsh hook
|
||||
_fasd_preexec() {
|
||||
{ eval "fasd --proc $(fasd --sanitize $2)"; } >> "/dev/null" 2>&1
|
||||
}
|
||||
autoload -Uz add-zsh-hook
|
||||
add-zsh-hook preexec _fasd_preexec
|
||||
|
||||
# zsh command mode completion
|
||||
_fasd_zsh_cmd_complete() {
|
||||
local compl
|
||||
read -c compl
|
||||
(( $+compstate )) && compstate[insert]=menu # no expand if compsys loaded
|
||||
reply=(${(f)"$(fasd --complete "$compl")"})
|
||||
}
|
||||
|
||||
# enable command mode completion
|
||||
compctl -U -K _fasd_zsh_cmd_complete -V fasd -x 'C[-1,-*e],s[-]n[1,e]' -c - \
|
||||
'c[-1,-A][-1,-D]' -f -- fasd fasd_cd
|
||||
|
||||
(( $+functions[compdef] )) && {
|
||||
# zsh word mode completion
|
||||
_fasd_zsh_word_complete() {
|
||||
[ "$2" ] && local _fasd_cur="$2"
|
||||
[ -z "$_fasd_cur" ] && local _fasd_cur="${words[CURRENT]}"
|
||||
local fnd="${_fasd_cur//,/ }"
|
||||
local typ=${1:-e}
|
||||
fasd --query $typ "$fnd" 2>> "/dev/null" | \
|
||||
sort -nr | sed 's/^[^ ]*[ ]*//' | while read -r line; do
|
||||
compadd -U -V fasd "$line"
|
||||
done
|
||||
compstate[insert]=menu # no expand
|
||||
}
|
||||
_fasd_zsh_word_complete_f() { _fasd_zsh_word_complete f ; }
|
||||
_fasd_zsh_word_complete_d() { _fasd_zsh_word_complete d ; }
|
||||
_fasd_zsh_word_complete_trigger() {
|
||||
local _fasd_cur="${words[CURRENT]}"
|
||||
eval $(fasd --word-complete-trigger _fasd_zsh_word_complete $_fasd_cur)
|
||||
}
|
||||
# define zle widgets
|
||||
zle -C fasd-complete complete-word _generic
|
||||
zstyle ':completion:fasd-complete:*' completer _fasd_zsh_word_complete
|
||||
zstyle ':completion:fasd-complete:*' menu-select
|
||||
|
||||
zle -C fasd-complete-f complete-word _generic
|
||||
zstyle ':completion:fasd-complete-f:*' completer _fasd_zsh_word_complete_f
|
||||
zstyle ':completion:fasd-complete-f:*' menu-select
|
||||
|
||||
zle -C fasd-complete-d complete-word _generic
|
||||
zstyle ':completion:fasd-complete-d:*' completer _fasd_zsh_word_complete_d
|
||||
zstyle ':completion:fasd-complete-d:*' menu-select
|
||||
}
|
||||
|
||||
(( $+functions[compdef] )) && {
|
||||
# enable word mode completion
|
||||
orig_comp="$(zstyle -L ':completion:\*' completer 2>> "/dev/null")"
|
||||
if [ "$orig_comp" ]; then
|
||||
case $orig_comp in
|
||||
*_fasd_zsh_word_complete_trigger*);;
|
||||
*) eval "$orig_comp _fasd_zsh_word_complete_trigger";;
|
||||
esac
|
||||
else
|
||||
zstyle ':completion:*' completer _complete _fasd_zsh_word_complete_trigger
|
||||
fi
|
||||
unset orig_comp
|
||||
}
|
|
@ -1,129 +0,0 @@
|
|||
git-info
|
||||
========
|
||||
|
||||
Exposes git repository status information to prompts.
|
||||
|
||||
Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) and
|
||||
[Colin Hebert](https://github.com/ColinHebert) for the original code.
|
||||
|
||||
Git **1.7.2** is the
|
||||
[minimum required version](https://github.com/sorin-ionescu/prezto/issues/219).
|
||||
|
||||
Settings
|
||||
--------
|
||||
|
||||
### Ignore submodules
|
||||
|
||||
Retrieving the status of a repository with submodules can take a long time.
|
||||
So by default 'all' submodules are ignored. Optionally, 'untracked', 'dirty', or
|
||||
'none' submodules can be ignored:
|
||||
|
||||
zstyle ':zim:git-info' ignore-submodules 'none'
|
||||
|
||||
### Verbose mode
|
||||
|
||||
Verbose mode uses `git status` and computes the count of indexed, unindexed and
|
||||
also untracked files. It can be enabled with the following zstyle:
|
||||
|
||||
zstyle ':zim:git-info' verbose yes
|
||||
|
||||
In non-verbose mode, the 'untracked' context is not available (see *Main
|
||||
contexts* below), and untracked files are also not considered for computing the
|
||||
'dirty' context. Using `git status` to check for untracked files can be
|
||||
[expensive](https://gist.github.com/sindresorhus/3898739).
|
||||
|
||||
Theming
|
||||
-------
|
||||
|
||||
To display information about the current repository in a prompt, define your
|
||||
custom styles in the `prompt_name_setup` function, where the syntax for setting
|
||||
a style is:
|
||||
|
||||
zstyle ':zim:git-info:context' format 'string'
|
||||
|
||||
### Main contexts
|
||||
|
||||
| Name | Code | Description
|
||||
| --------- | :----: | ---------------------------------------------------------
|
||||
| action | %s | Special action name (see *Special action contexts* below)
|
||||
| ahead | %A | Commits ahead of remote count
|
||||
| behind | %B | Commits behind of remote count
|
||||
| diverged | %V | Diverged commits (both ahead and behind are yield when it's not defined)
|
||||
| branch | %b | Branch name
|
||||
| commit | %c | Commit short hash (when in 'detached HEAD' state)
|
||||
| clean | %C | Clean state
|
||||
| dirty | %D | Dirty state (count with untracked files when verbose mode enabled)
|
||||
| indexed | %i | Indexed files (count when verbose mode enabled)
|
||||
| unindexed | %I | Unindexed files (count when verbose mode enabled)
|
||||
| position | %p | Commits from nearest tag count (when in 'detached HEAD' state)
|
||||
| remote | %R | Remote name
|
||||
| stashed | %S | Stashed states count
|
||||
| untracked | %u | Untracked files count (only when verbose mode enabled)
|
||||
|
||||
While `commit` and `position` are only available when in ['detached HEAD'
|
||||
state](http://gitfaq.org/articles/what-is-a-detached-head.html), on the other
|
||||
hand, `ahead`, `behind`, `diverged`, `branch` and `remote` are only available
|
||||
when an actual branch is checked out (so when **not** in 'detached HEAD' state).
|
||||
|
||||
### Special action contexts
|
||||
|
||||
| Name | Format | Default Value
|
||||
| --------------------------- | :-----: | --------------------------------------
|
||||
| action:apply | value | 'apply'
|
||||
| action:bisect | value | 'bisect'
|
||||
| action:cherry-pick | value | 'cherry-pick'
|
||||
| action:cherry-pick-sequence | value | 'cherry-pick-sequence'
|
||||
| action:merge | value | 'merge'
|
||||
| action:rebase | value | 'rebase'
|
||||
| action:rebase-interactive | value | 'rebase-interactive'
|
||||
| action:rebase-merge | value | 'rebase-merge'
|
||||
|
||||
Formatting example for special actions:
|
||||
|
||||
zstyle ':zim:git-info:action:bisect' format '<B>'
|
||||
zstyle ':zim:git-info:action:merge' format '>M<'
|
||||
zstyle ':zim:git-info:action:rebase' format '>R>'
|
||||
|
||||
### Usage
|
||||
|
||||
First, format the repository state attributes. For example, to format the
|
||||
branch name, commit, and remote name, define the following styles:
|
||||
|
||||
zstyle ':zim:git-info:branch' format 'branch:%b'
|
||||
zstyle ':zim:git-info:commit' format 'commit:%c'
|
||||
zstyle ':zim:git-info:remote' format 'remote:%R'
|
||||
|
||||
Second, format how the above attributes are displayed in prompts:
|
||||
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' 'git(%b%c)' \
|
||||
'rprompt' '[%R]'
|
||||
|
||||
Last, add `${(e)git_info[prompt]}` and `${(e)git_info[rprompt]}` to `PS1` and
|
||||
`RPS1` respectively, and call `git-info` in the `prompt_name_precmd` hook function.
|
||||
|
||||
Here's a complete example of a `prompt_example_setup` file:
|
||||
```zsh
|
||||
prompt_example_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_example_setup() {
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_example_precmd
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
zstyle ':zim:git-info:branch' format 'branch:%b'
|
||||
zstyle ':zim:git-info:commit' format 'commit:%c'
|
||||
zstyle ':zim:git-info:remote' format 'remote:%R'
|
||||
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' 'git(%b%c)' \
|
||||
'rprompt' '[%R]'
|
||||
|
||||
PS1='${(e)git_info[prompt]}%# '
|
||||
RPS1='${(e)git_info[rprompt]}'
|
||||
}
|
||||
|
||||
prompt_example_setup "${@}"
|
||||
```
|
|
@ -1,8 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
# Prints the first non-empty string in the arguments array.
|
||||
local arg
|
||||
for arg in ${argv}; do
|
||||
print -n ${arg}
|
||||
return 0
|
||||
done
|
||||
return 1
|
|
@ -1,80 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
# Gets the Git special action (am, bisect, cherry, merge, rebase).
|
||||
# Borrowed from vcs_info and edited.
|
||||
local git_dir=${$(command git rev-parse --git-dir):A}
|
||||
local action_dir
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-apply" \
|
||||
"${git_dir}/rebase" \
|
||||
"${git_dir}/../.dotest"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local apply_formatted rebase_formatted
|
||||
zstyle -s ':zim:git-info:action:apply' format 'apply_formatted' || apply_formatted='apply'
|
||||
zstyle -s ':zim:git-info:action:rebase' format 'rebase_formatted' || rebase_formatted='rebase'
|
||||
|
||||
if [[ -f "${action_dir}/rebasing" ]]; then
|
||||
print ${rebase_formatted}
|
||||
elif [[ -f "${action_dir}/applying" ]]; then
|
||||
print ${apply_formatted}
|
||||
else
|
||||
print "${rebase_formatted}/${apply_formatted}"
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge/interactive" \
|
||||
"${git_dir}/.dotest-merge/interactive"
|
||||
do
|
||||
if [[ -f ${action_dir} ]]; then
|
||||
local rebase_interactive_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-interactive' format 'rebase_interactive_formatted' || rebase_interactive_formatted='rebase-interactive'
|
||||
print ${rebase_interactive_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
for action_dir in \
|
||||
"${git_dir}/rebase-merge" \
|
||||
"${git_dir}/.dotest-merge"
|
||||
do
|
||||
if [[ -d ${action_dir} ]]; then
|
||||
local rebase_merge_formatted
|
||||
zstyle -s ':zim:git-info:action:rebase-merge' format 'rebase_merge_formatted' || rebase_merge_formatted='rebase-merge'
|
||||
print ${rebase_merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
done
|
||||
|
||||
if [[ -f "${git_dir}/MERGE_HEAD" ]]; then
|
||||
local merge_formatted
|
||||
zstyle -s ':zim:git-info:action:merge' format 'merge_formatted' || merge_formatted='merge'
|
||||
print ${merge_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/CHERRY_PICK_HEAD" ]]; then
|
||||
if [[ -d "${git_dir}/sequencer" ]]; then
|
||||
local cherry_pick_sequence_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick-sequence' format 'cherry_pick_sequence_formatted' || cherry_pick_sequence_formatted='cherry-pick-sequence'
|
||||
print ${cherry_pick_sequence_formatted}
|
||||
else
|
||||
local cherry_pick_formatted
|
||||
zstyle -s ':zim:git-info:action:cherry-pick' format 'cherry_pick_formatted' || cherry_pick_formatted='cherry-pick'
|
||||
print ${cherry_pick_formatted}
|
||||
fi
|
||||
|
||||
return 0
|
||||
fi
|
||||
|
||||
if [[ -f "${git_dir}/BISECT_LOG" ]]; then
|
||||
local bisect_formatted
|
||||
zstyle -s ':zim:git-info:action:bisect' format 'bisect_formatted' || bisect_formatted='bisect'
|
||||
print ${bisect_formatted}
|
||||
return 0
|
||||
fi
|
||||
|
||||
return 1
|
|
@ -1,224 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Exposes Git repository information via the git_info associative array.
|
||||
#
|
||||
|
||||
# Extended globbing is needed to parse repository status.
|
||||
setopt LOCAL_OPTIONS EXTENDED_GLOB
|
||||
|
||||
# Clean up previous git_info.
|
||||
unset git_info
|
||||
typeset -gA git_info
|
||||
|
||||
# Return if not inside a Git repository work tree.
|
||||
if ! command git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Ignore submodule status.
|
||||
local ignore_submodules
|
||||
zstyle -s ':zim:git-info' ignore-submodules 'ignore_submodules' || ignore_submodules='all'
|
||||
|
||||
# Format stashed.
|
||||
local stashed_format stashed_formatted
|
||||
if zstyle -s ':zim:git-info:stashed' format 'stashed_format'; then
|
||||
local -i stashed=$(command git stash list 2>/dev/null | wc -l)
|
||||
(( stashed )) && zformat -f stashed_formatted ${stashed_format} "S:${stashed}"
|
||||
fi
|
||||
|
||||
# Format action.
|
||||
local action_format action_formatted
|
||||
if zstyle -s ':zim:git-info:action' format 'action_format'; then
|
||||
local action=$(git-action)
|
||||
if [[ -n ${action} ]]; then
|
||||
zformat -f action_formatted ${action_format} "s:${action}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# The contents of git_info are subject to expansion by the shell. Avoid
|
||||
# putting raw ref names in the prompt to protect the user from arbitrary code
|
||||
# execution via specially crafted ref names (e.g., a ref named
|
||||
# '$(IFS=_;cmd=sudo_rm_-rf_/;$cmd)' would execute 'sudo rm -rf /' when the
|
||||
# prompt is drawn). Instead, put the ref names in new global variables and
|
||||
# reference these variables from git_info.
|
||||
# See https://github.com/njhartwell/pw3nage
|
||||
|
||||
# Get the branch.
|
||||
__GIT_INFO_BRANCH=$(command git symbolic-ref -q --short HEAD 2>/dev/null)
|
||||
|
||||
local ahead_formatted behind_formatted branch_formatted commit_formatted diverged_formatted position_formatted remote_formatted
|
||||
if [[ -n ${__GIT_INFO_BRANCH} ]]; then
|
||||
unset __GIT_INFO_POSITION
|
||||
|
||||
# Format branch.
|
||||
local branch_format
|
||||
if zstyle -s ':zim:git-info:branch' format 'branch_format'; then
|
||||
zformat -f branch_formatted ${branch_format} 'b:${__GIT_INFO_BRANCH}'
|
||||
fi
|
||||
|
||||
# Format remote.
|
||||
local remote_format
|
||||
if zstyle -s ':zim:git-info:remote' format 'remote_format'; then
|
||||
# Gets the remote name.
|
||||
local remote_cmd='command git rev-parse --symbolic-full-name --verify HEAD@{upstream}'
|
||||
__GIT_INFO_REMOTE=${$(${(z)remote_cmd} 2>/dev/null)##refs/remotes/}
|
||||
if [[ -n ${__GIT_INFO_REMOTE} ]]; then
|
||||
zformat -f remote_formatted ${remote_format} 'R:${__GIT_INFO_REMOTE}'
|
||||
else
|
||||
unset __GIT_INFO_REMOTE
|
||||
fi
|
||||
fi
|
||||
|
||||
local ahead_format behind_format diverged_format
|
||||
zstyle -s ':zim:git-info:ahead' format 'ahead_format'
|
||||
zstyle -s ':zim:git-info:behind' format 'behind_format'
|
||||
zstyle -s ':zim:git-info:diverged' format 'diverged_format'
|
||||
if [[ -n ${ahead_format} || -n ${behind_format} || -n ${diverged_format} ]]; then
|
||||
# Gets the commit difference counts between local and remote.
|
||||
local ahead_and_behind_cmd='command git rev-list --count --left-right HEAD...@{upstream}'
|
||||
|
||||
# Get ahead and behind counts.
|
||||
local ahead_and_behind=$(${(z)ahead_and_behind_cmd} 2>/dev/null)
|
||||
local -i ahead=${ahead_and_behind[(w)1]}
|
||||
local -i behind=${ahead_and_behind[(w)2]}
|
||||
|
||||
if [[ -n ${diverged_format} && ${ahead} -gt 0 && ${behind} -gt 0 ]]; then
|
||||
# Format diverged.
|
||||
diverged_formatted=${diverged_format}
|
||||
else
|
||||
# Format ahead.
|
||||
if [[ -n ${ahead_format} && ${ahead} -gt 0 ]]; then
|
||||
zformat -f ahead_formatted ${ahead_format} "A:${ahead}"
|
||||
fi
|
||||
# Format behind.
|
||||
if [[ -n ${behind_format} && ${behind} -gt 0 ]]; then
|
||||
zformat -f behind_formatted ${behind_format} "B:${behind}"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
else
|
||||
unset __GIT_INFO_BRANCH
|
||||
unset __GIT_INFO_REMOTE
|
||||
|
||||
# Format commit.
|
||||
local commit_format
|
||||
if zstyle -s ':zim:git-info:commit' format 'commit_format'; then
|
||||
local commit=$(command git rev-parse --short HEAD 2>/dev/null)
|
||||
if [[ -n ${commit} ]]; then
|
||||
zformat -f commit_formatted ${commit_format} "c:${commit}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format position.
|
||||
local position_format
|
||||
if zstyle -s ':zim:git-info:position' format 'position_format'; then
|
||||
__GIT_INFO_POSITION=$(command git describe --contains --all HEAD 2>/dev/null)
|
||||
if [[ -n ${__GIT_INFO_POSITION} ]]; then
|
||||
zformat -f position_formatted ${position_format} 'p:${__GIT_INFO_POSITION}'
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
# Dirty and clean format.
|
||||
local dirty_format dirty_formatted clean_format clean_formatted
|
||||
zstyle -s ':zim:git-info:dirty' format 'dirty_format'
|
||||
zstyle -s ':zim:git-info:clean' format 'clean_format'
|
||||
|
||||
local -i dirty
|
||||
local indexed_formatted unindexed_formatted untracked_formatted
|
||||
if ! zstyle -t ':zim:git-info' verbose; then
|
||||
# Format unindexed.
|
||||
local unindexed_format
|
||||
zstyle -s ':zim:git-info:unindexed' format 'unindexed_format'
|
||||
if [[ -n ${unindexed_format} || -n ${dirty_format} || -n ${clean_format} ]]; then
|
||||
if ! command git diff-files --no-ext-diff --quiet --ignore-submodules=${ignore_submodules} &>/dev/null; then
|
||||
unindexed_formatted=${unindexed_format}
|
||||
dirty=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format indexed.
|
||||
local indexed_format
|
||||
zstyle -s ':zim:git-info:indexed' format 'indexed_format'
|
||||
if [[ -n ${indexed_format} || (${dirty} -eq 0 && (-n ${dirty_format} || -n ${clean_format})) ]]; then
|
||||
if ! command git diff-index --no-ext-diff --quiet --cached --ignore-submodules=${ignore_submodules} HEAD &>/dev/null; then
|
||||
indexed_formatted=${indexed_format}
|
||||
dirty=1
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format dirty and clean.
|
||||
if (( dirty )); then
|
||||
dirty_formatted=${dirty_format}
|
||||
else
|
||||
clean_formatted=${clean_format}
|
||||
fi
|
||||
else
|
||||
# Use porcelain status for easy parsing.
|
||||
local status_cmd="command git status --porcelain --ignore-submodules=${ignore_submodules}"
|
||||
|
||||
local -i indexed unindexed untracked
|
||||
# Get current status.
|
||||
while IFS=$'\n' read line; do
|
||||
if [[ ${line:0:2} == '??' ]]; then
|
||||
(( untracked++ ))
|
||||
else
|
||||
[[ ${line:0:1} != ' ' ]] && (( indexed++ ))
|
||||
[[ ${line:1:1} != ' ' ]] && (( unindexed++ ))
|
||||
fi
|
||||
(( dirty++ ))
|
||||
done < <(${(z)status_cmd} 2>/dev/null)
|
||||
|
||||
# Format indexed.
|
||||
if (( indexed )); then
|
||||
local indexed_format
|
||||
zstyle -s ':zim:git-info:indexed' format 'indexed_format'
|
||||
zformat -f indexed_formatted ${indexed_format} "i:${indexed}"
|
||||
fi
|
||||
|
||||
# Format unindexed.
|
||||
if (( unindexed )); then
|
||||
local unindexed_format
|
||||
zstyle -s ':zim:git-info:unindexed' format 'unindexed_format'
|
||||
zformat -f unindexed_formatted ${unindexed_format} "I:${unindexed}"
|
||||
fi
|
||||
|
||||
# Format untracked.
|
||||
if (( untracked )); then
|
||||
local untracked_format
|
||||
zstyle -s ':zim:git-info:untracked' format 'untracked_format'
|
||||
zformat -f untracked_formatted ${untracked_format} "u:${untracked}"
|
||||
fi
|
||||
|
||||
# Format dirty and clean.
|
||||
if (( dirty )); then
|
||||
zformat -f dirty_formatted ${dirty_format} "u:${dirty}"
|
||||
else
|
||||
clean_formatted=${clean_format}
|
||||
fi
|
||||
fi
|
||||
|
||||
# Format info.
|
||||
local -A info_formats
|
||||
local info_format reply
|
||||
zstyle -a ':zim:git-info:keys' format 'info_formats'
|
||||
for info_format in ${(k)info_formats}; do
|
||||
zformat -f reply "${info_formats[${info_format}]}" \
|
||||
"A:${ahead_formatted}" \
|
||||
"B:${behind_formatted}" \
|
||||
"b:${branch_formatted}" \
|
||||
"C:${clean_formatted}" \
|
||||
"c:${commit_formatted}" \
|
||||
"D:${dirty_formatted}" \
|
||||
"i:${indexed_formatted}" \
|
||||
"I:${unindexed_formatted}" \
|
||||
"p:${position_formatted}" \
|
||||
"R:${remote_formatted}" \
|
||||
"s:${action_formatted}" \
|
||||
"S:${stashed_formatted}" \
|
||||
"u:${untracked_formatted}" \
|
||||
"V:${diverged_formatted}"
|
||||
git_info[${info_format}]=${reply}
|
||||
done
|
||||
|
||||
return 0
|
|
@ -1,236 +0,0 @@
|
|||
git
|
||||
===
|
||||
|
||||
Provides handy git aliases and functions.
|
||||
|
||||
Many thanks to [Sorin Ionescu](https://github.com/sorin-ionescu) for the
|
||||
excellent original aliases.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### Git
|
||||
|
||||
* `g` is short for `git`.
|
||||
|
||||
### Branch
|
||||
|
||||
* `gb` lists, creates, renames, and deletes branches.
|
||||
* `gbc` creates a new branch.
|
||||
* `gbl` lists branches and their commits.
|
||||
* `gbL` lists local and remote branches and their commits.
|
||||
* `gbm` renames a branch.
|
||||
* `gbM` renames a branch even if the new branch name already exists.
|
||||
* `gbs` lists branches and their commits with ancestry graphs.
|
||||
* `gbS` lists local and remote branches and their commits with ancestry
|
||||
graphs.
|
||||
* `gbx` deletes a branch.
|
||||
* `gbX` deletes a branch irrespective of its merged status.
|
||||
|
||||
### Commit
|
||||
|
||||
* `gc` records changes to the repository.
|
||||
* `gca` commits all modified and deleted files.
|
||||
* `gcm` commits with the given message.
|
||||
* `gco` checks out a branch or paths to the working tree.
|
||||
* `gcO` checks out hunks from the index or the tree interactively.
|
||||
* `gcf` amends the tip of the current branch reusing the same log message as
|
||||
*HEAD*.
|
||||
* `gcF` amends the tip of the current branch.
|
||||
* `gcp` applies changes introduced by existing commits.
|
||||
* `gcP` applies changes introduced by existing commits without committing.
|
||||
* `gcr` reverts existing commits by reverting patches and recording new
|
||||
commits.
|
||||
* `gcR` removes the *HEAD* commit.
|
||||
* `gcs` shows one or more objects (blobs, trees, tags and commits).
|
||||
* `gcS` commits with GPG signature.
|
||||
* `gcv` verifies the GPG signature of commits.
|
||||
|
||||
### Conflict
|
||||
|
||||
* `gCl` lists unmerged files.
|
||||
* `gCa` adds unmerged file contents to the index.
|
||||
* `gCe` executes merge-tool on all unmerged files.
|
||||
* `gCo` checks out our changes for unmerged paths.
|
||||
* `gCO` checks out our changes for all unmerged paths.
|
||||
* `gCt` checks out their changes for unmerged paths.
|
||||
* `gCT` checks out their changes for all unmerged paths.
|
||||
|
||||
### Data
|
||||
|
||||
* `gd` displays information about files in the index and the work tree.
|
||||
* `gdc` lists cached files.
|
||||
* `gdx` lists deleted files.
|
||||
* `gdm` lists modified files.
|
||||
* `gdu` lists untracked files.
|
||||
* `gdk` lists killed files.
|
||||
* `gdi` lists ignored files.
|
||||
|
||||
### Fetch
|
||||
|
||||
* `gf` downloads objects and references from another repository.
|
||||
* `gfc` clones a repository into a new directory.
|
||||
* `gfm` fetches from and merges with another repository or local branch.
|
||||
* `gfr` fetches from and rebases on top of another repository or local branch.
|
||||
* `gfu` removes unexisting remote-tracking references, fetches all remotes and
|
||||
merges.
|
||||
|
||||
### Grep
|
||||
|
||||
* `gg` displays lines matching a pattern.
|
||||
* `ggi` displays lines matching a pattern ignoring case.
|
||||
* `ggl` lists files matching a pattern.
|
||||
* `ggL` lists files that are not matching a pattern.
|
||||
* `ggv` displays lines not matching a pattern.
|
||||
* `ggw` displays lines matching a pattern at word boundary.
|
||||
|
||||
### Index
|
||||
|
||||
* `gia` adds file contents to the index.
|
||||
* `giA` adds file contents to the index interactively.
|
||||
* `giu` adds file contents to the index (updates only known files).
|
||||
* `gid` displays changes between the index and a named commit (diff).
|
||||
* `giD` displays changes between the index and a named commit (word diff).
|
||||
* `gir` resets the current *HEAD* to the specified state.
|
||||
* `giR` resets the current index interactively.
|
||||
* `gix` removes files/directories from the index (recursively).
|
||||
* `giX` removes files/directories from the index (recursively and forced).
|
||||
|
||||
### Log
|
||||
|
||||
* `gl` displays the log.
|
||||
* `gls` displays the stats log.
|
||||
* `gld` displays the diff log.
|
||||
* `glo` displays the one line log.
|
||||
* `glO` displays the one line log with authors and dates.
|
||||
* `glg` displays the graph log.
|
||||
* `glG` displays the graph log with authors and dates.
|
||||
* `glv` displays the log verifying the GPG signature of commits.
|
||||
* `glc` displays the commit count for each contributor in descending order.
|
||||
|
||||
### Merge
|
||||
|
||||
* `gm` joins two or more development histories together.
|
||||
* `gmC` performs the merge but does not commit.
|
||||
* `gmF` performs the merge generating a commit even if the merge resolved as a
|
||||
fast-forward.
|
||||
* `gma` aborts the conflict resolution, and reconstructs the pre-merge state.
|
||||
* `gmt` runs the merge conflict resolution tools to resolve conflicts.
|
||||
|
||||
### Push
|
||||
|
||||
* `gp` updates remote refs along with associated objects.
|
||||
* `gpf` forces a push safely (with "lease").
|
||||
* `gpF` forces a push.
|
||||
* `gpa` pushes all branches.
|
||||
* `gpA` pushes all branches and tags.
|
||||
* `gpt` pushes all tags.
|
||||
* `gpc` pushes the current branch and adds *origin* as an upstream reference
|
||||
for it.
|
||||
* `gpp` pulls and pushes the current branch from *origin* to *origin*.
|
||||
|
||||
### Rebase
|
||||
|
||||
* `gr` forward-ports local commits to the updated upstream head.
|
||||
* `gra` aborts the rebase.
|
||||
* `grc` continues the rebase after merge conflicts are resolved.
|
||||
* `gri` makes a list of commits to be rebased and opens the editor.
|
||||
* `grs` skips the current patch.
|
||||
|
||||
### Remote
|
||||
|
||||
* `gR` manages tracked repositories.
|
||||
* `gRl` lists remote names and their URLs.
|
||||
* `gRa` adds a new remote.
|
||||
* `gRx` removes a remote.
|
||||
* `gRm` renames a remote.
|
||||
* `gRu` fetches remotes updates.
|
||||
* `gRp` prunes all stale remote tracking branches.
|
||||
* `gRs` shows information about a given remote.
|
||||
|
||||
### Stash
|
||||
|
||||
* `gs` stashes the changes of the dirty working directory.
|
||||
* `gsa` applies the changes recorded in a stash to the working directory.
|
||||
* `gsx` drops a stashed state.
|
||||
* `gsX` drops all the stashed states.
|
||||
* `gsl` lists stashed states.
|
||||
* `gsd` displays changes between the stash and its original parent.
|
||||
* `gsp` removes and applies a single stashed state from the stash list.
|
||||
* `gsr` recovers a given stashed state.
|
||||
* `gss` stashes the working directory changes, including untracked files.
|
||||
* `gsS` stashes the working directory changes interactively.
|
||||
* `gsw` stashes the working directory changes retaining the index.
|
||||
* `gsu` unapplies (reverts) applied changes.
|
||||
|
||||
### Submodule
|
||||
|
||||
* `gS` initializes, updates, or inspects submodules.
|
||||
* `gSa` adds given a repository as a submodule.
|
||||
* `gSf` evaluates a shell command in each of checked out submodules.
|
||||
* `gSi` initializes submodules.
|
||||
* `gSI` initializes and clones submodules recursively.
|
||||
* `gSl` lists the commits of all submodules.
|
||||
* `gSm` moves a submodule.
|
||||
* `gSs` synchronizes submodules' remote URL to the value specified in
|
||||
`.gitmodules`.
|
||||
* `gSu` fetches and merges the latest changes for all submodules.
|
||||
* `gSx` removes a submodule.
|
||||
|
||||
### Tag
|
||||
|
||||
* `gt` creates, lists, deletes or verifies a tag object signed with GPG.
|
||||
* `gts` creates a GPG-signed tag.
|
||||
* `gtv` verifies the GPG signature of tags.
|
||||
* `gtx` deletes tags with given names.
|
||||
|
||||
### Working tree
|
||||
|
||||
* `gws` displays working-tree status in the short format.
|
||||
* `gwS` displays working-tree status.
|
||||
* `gwd` displays changes between the working tree and the index (diff).
|
||||
* `gwD` displays changes between the working tree and the index (word diff).
|
||||
* `gwr` resets the current *HEAD* to the specified state, does not touch the
|
||||
index nor the working tree.
|
||||
* `gwR` resets the current *HEAD*, index and working tree to the specified
|
||||
state.
|
||||
* `gwc` cleans untracked files from the working tree (dry-run).
|
||||
* `gwC` cleans untracked files from the working tree.
|
||||
* `gwx` removes files from the working tree and from the index recursively.
|
||||
* `gwX` removes files from the working tree and from the index recursively and
|
||||
forcefully.
|
||||
|
||||
### Misc
|
||||
|
||||
* `g..` changes the current directory to the top level of the working tree.
|
||||
|
||||
### Shadows
|
||||
|
||||
The following aliases may shadow system commands:
|
||||
|
||||
* `gb` shadows a [build tool for the Go programming language](https://getgb.io/).
|
||||
* `gm` shadows [GraphicsMagick](http://www.graphicsmagick.org/).
|
||||
* `gpt` shadows the GUID partition table maintenance utility.
|
||||
* `grc` shadows [Generic Colouriser](https://github.com/garabik/grc).
|
||||
* `gs` shadows [Ghostscript](https://www.ghostscript.com/).
|
||||
|
||||
If you frequently use the above commands, you may wish to disable this module
|
||||
altogether, or to disable the specific aliases with `unalias` at the bottom of
|
||||
your `.zshrc`.
|
||||
|
||||
You can temporarily bypass an alias by prefixing it with a backward slash:
|
||||
`\gpt`.
|
||||
|
||||
Functions
|
||||
---------
|
||||
|
||||
* `git-branch-current` displays the current branch.
|
||||
* `git-branch-delete-interactive` asks for confirmation to also delete the
|
||||
upstream remote branch(es).
|
||||
* `git-dir` displays the path to the Git directory.
|
||||
* `git-ignore-add` adds any arguments to the .gitignore in the project root.
|
||||
* `git-root` displays the path to the working tree root.
|
||||
* `git-stash-clear-interactive` asks for confirmation before clearing the stash.
|
||||
* `git-stash-recover` recovers given dropped stashed states.
|
||||
* `git-submodule-move` moves a submodule.
|
||||
* `git-submodule-remove` removes a submodule.
|
|
@ -1,3 +0,0 @@
|
|||
#compdef git-branch-delete-interactive
|
||||
|
||||
words[1]=(git branch); (( CURRENT++ )); service=git; _git
|
|
@ -1,2 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
command git symbolic-ref -q --short HEAD
|
|
@ -1,14 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local -a remotes
|
||||
if (( ${*[(I)(-r|--remotes)]} )); then
|
||||
remotes=(${^*:#-*})
|
||||
else
|
||||
remotes=(${(f)"$(command git rev-parse --abbrev-ref ${^*:#-*}@{u} 2>/dev/null)"}) || remotes=()
|
||||
fi
|
||||
if command git branch --delete ${@} && \
|
||||
(( ${#remotes} )) && \
|
||||
read -q "?Also delete remote branch(es) ${remotes} [y/N]? "; then
|
||||
print
|
||||
local remote
|
||||
for remote (${remotes}) command git push ${remote%%/*} :${remote#*/}
|
||||
fi
|
|
@ -1,4 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_dir
|
||||
git_dir=$(command git rev-parse --git-dir) || return 1
|
||||
print ${git_dir:A}
|
|
@ -1,6 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_root
|
||||
git_root=$(git-root) || return 1
|
||||
|
||||
# we are in a git repository. add parameters to .gitignore
|
||||
for file (${@}) print ${file} >>! "${git_root}/.gitignore"
|
|
@ -1,2 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
command git rev-parse --show-toplevel
|
|
@ -1,10 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
setopt LOCAL_OPTIONS PIPE_FAIL
|
||||
|
||||
local -i stashed
|
||||
stashed=$(command git stash list | wc -l) || return 1
|
||||
if (( stashed )) && \
|
||||
read -q "?Clear ${stashed} stashed state(s) [y/N]? "; then
|
||||
print
|
||||
command git stash clear
|
||||
fi
|
|
@ -1,8 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
command git rev-parse --is-inside-work-tree >/dev/null || return 1
|
||||
|
||||
local commit
|
||||
for commit in "${@}"; do
|
||||
git update-ref -m "$(command git log -1 --pretty='format:%s' ${commit})" \
|
||||
refs/stash ${commit}
|
||||
done
|
|
@ -1,22 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_root
|
||||
git_root=$(git-root) || return 1
|
||||
|
||||
if [[ ${PWD} != ${git_root} ]]; then
|
||||
print "${0}: must be run from the root of the work tree" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
local src="${1}"
|
||||
local dst="${2}"
|
||||
local url=$(command git config --file .gitmodules --get "submodule.${src}.url")
|
||||
if [[ -z "${url}" ]]; then
|
||||
print "${0}: submodule not found: ${src}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
mkdir -p "${dst:h}"
|
||||
git-submodule-remove "${src}"
|
||||
git submodule add "${url}" "${dst}"
|
||||
|
||||
return 0
|
|
@ -1,21 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
local git_dir
|
||||
git_dir=$(git-dir) || return 1
|
||||
|
||||
if [[ ${PWD} != $(git-root) ]]; then
|
||||
print "${0}: must be run from the root of the work tree" >&2
|
||||
return 1
|
||||
elif ! command git config --file .gitmodules --get "submodule.${1}.path" &>/dev/null; then
|
||||
print "${0}: submodule not found: ${1}" >&2
|
||||
return 1
|
||||
fi
|
||||
|
||||
command git config --file "${git_dir}/config" --remove-section "submodule.${1}" &>/dev/null
|
||||
command git config --file .gitmodules --remove-section "submodule.${1}" &>/dev/null
|
||||
command git add .gitmodules
|
||||
|
||||
command git rm --cached "${1}" &>/dev/null
|
||||
rm -rf "${1}"
|
||||
rm -rf "${git_dir}/modules/${1}"
|
||||
|
||||
return 0
|
|
@ -1,184 +0,0 @@
|
|||
#
|
||||
# Git aliases.
|
||||
#
|
||||
|
||||
#
|
||||
# Settings
|
||||
#
|
||||
|
||||
# Log colour scheme has yellow commit hash, bold blue author, cyan date, auto ref names
|
||||
# See https://git-scm.com/docs/pretty-formats
|
||||
_git_log_medium_format='%C(bold)Commit:%C(reset) %C(yellow)%H%C(auto)%d%n%C(bold)Author:%C(reset) %C(bold blue)%an <%ae>%n%C(bold)Date:%C(reset) %C(cyan)%ai (%ar)%C(reset)%n%+B'
|
||||
_git_log_oneline_format='%C(yellow)%h%C(reset) %s%C(auto)%d%C(reset)'
|
||||
_git_log_oneline_medium_format='%C(yellow)%h%C(reset) %<|(60,trunc)%s %C(bold blue)<%an> %C(reset)%C(cyan)(%ar)%C(auto)%d%C(reset)'
|
||||
|
||||
#
|
||||
# Aliases
|
||||
#
|
||||
|
||||
# Git
|
||||
alias g='git'
|
||||
|
||||
# Branch (b)
|
||||
alias gb='git branch'
|
||||
alias gbc='git checkout -b'
|
||||
alias gbl='git branch -vv'
|
||||
alias gbL='git branch --all -vv'
|
||||
alias gbm='git branch --move'
|
||||
alias gbM='git branch --move --force'
|
||||
alias gbs='git show-branch'
|
||||
alias gbS='git show-branch --all'
|
||||
alias gbx='git-branch-delete-interactive'
|
||||
alias gbX='git-branch-delete-interactive --force'
|
||||
|
||||
# Commit (c)
|
||||
alias gc='git commit --verbose'
|
||||
alias gca='git commit --verbose --all'
|
||||
alias gcm='git commit --message'
|
||||
alias gco='git checkout'
|
||||
alias gcO='git checkout --patch'
|
||||
alias gcf='git commit --amend --reuse-message HEAD'
|
||||
alias gcF='git commit --verbose --amend'
|
||||
alias gcp='git cherry-pick --ff'
|
||||
alias gcP='git cherry-pick --no-commit'
|
||||
alias gcr='git revert'
|
||||
alias gcR='git reset "HEAD^"'
|
||||
alias gcs='git show --pretty=format:"${_git_log_medium_format}"'
|
||||
alias gcS='git commit -S'
|
||||
alias gcv='git verify-commit'
|
||||
|
||||
# Conflict (C)
|
||||
alias gCl='git --no-pager diff --diff-filter=U --name-only'
|
||||
alias gCa='git add $(gCl)'
|
||||
alias gCe='git mergetool $(gCl)'
|
||||
alias gCo='git checkout --ours --'
|
||||
alias gCO='gCo $(gCl)'
|
||||
alias gCt='git checkout --theirs --'
|
||||
alias gCT='gCt $(gCl)'
|
||||
|
||||
# Data (d)
|
||||
alias gd='git ls-files'
|
||||
alias gdc='git ls-files --cached'
|
||||
alias gdx='git ls-files --deleted'
|
||||
alias gdm='git ls-files --modified'
|
||||
alias gdu='git ls-files --other --exclude-standard'
|
||||
alias gdk='git ls-files --killed'
|
||||
alias gdi='git status --porcelain --short --ignored | sed -n "s/^!! //p"'
|
||||
|
||||
# Fetch (f)
|
||||
alias gf='git fetch'
|
||||
alias gfc='git clone'
|
||||
alias gfm='git pull'
|
||||
alias gfr='git pull --rebase'
|
||||
alias gfu='git fetch --all --prune && git merge --ff-only @\{u\}'
|
||||
|
||||
# Grep (g)
|
||||
alias gg='git grep'
|
||||
alias ggi='git grep --ignore-case'
|
||||
alias ggl='git grep --files-with-matches'
|
||||
alias ggL='git grep --files-without-match'
|
||||
alias ggv='git grep --invert-match'
|
||||
alias ggw='git grep --word-regexp'
|
||||
|
||||
# Index (i)
|
||||
alias gia='git add'
|
||||
alias giA='git add --patch'
|
||||
alias giu='git add --update'
|
||||
alias gid='git diff --no-ext-diff --cached'
|
||||
alias giD='git diff --no-ext-diff --cached --word-diff'
|
||||
alias gir='git reset'
|
||||
alias giR='git reset --patch'
|
||||
alias gix='git rm --cached -r'
|
||||
alias giX='git rm --cached -rf'
|
||||
|
||||
# Log (l)
|
||||
alias gl='git log --topo-order --pretty=format:"${_git_log_medium_format}"'
|
||||
alias gls='git log --topo-order --stat --pretty=format:"${_git_log_medium_format}"'
|
||||
alias gld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_medium_format}"'
|
||||
alias glo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"'
|
||||
alias glO='git log --topo-order --pretty=format:"${_git_log_oneline_medium_format}"'
|
||||
alias glg='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_format}"'
|
||||
alias glG='git log --topo-order --all --graph --pretty=format:"${_git_log_oneline_medium_format}"'
|
||||
alias glv='git log --topo-order --show-signature --pretty=format:"${_git_log_medium_format}"'
|
||||
alias glc='git shortlog --summary --numbered'
|
||||
|
||||
# Merge (m)
|
||||
alias gm='git merge'
|
||||
alias gmC='git merge --no-commit'
|
||||
alias gmF='git merge --no-ff'
|
||||
alias gma='git merge --abort'
|
||||
alias gmt='git mergetool'
|
||||
|
||||
# Push (p)
|
||||
alias gp='git push'
|
||||
alias gpf='git push --force-with-lease'
|
||||
alias gpF='git push --force'
|
||||
alias gpa='git push --all'
|
||||
alias gpA='git push --all && git push --tags'
|
||||
alias gpt='git push --tags'
|
||||
alias gpc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"'
|
||||
alias gpp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"'
|
||||
|
||||
# Rebase (r)
|
||||
alias gr='git rebase'
|
||||
alias gra='git rebase --abort'
|
||||
alias grc='git rebase --continue'
|
||||
alias gri='git rebase --interactive'
|
||||
alias grs='git rebase --skip'
|
||||
|
||||
# Remote (R)
|
||||
alias gR='git remote'
|
||||
alias gRl='git remote --verbose'
|
||||
alias gRa='git remote add'
|
||||
alias gRx='git remote rm'
|
||||
alias gRm='git remote rename'
|
||||
alias gRu='git remote update'
|
||||
alias gRp='git remote prune'
|
||||
alias gRs='git remote show'
|
||||
|
||||
# Stash (s)
|
||||
alias gs='git stash'
|
||||
alias gsa='git stash apply'
|
||||
alias gsx='git stash drop'
|
||||
alias gsX='git-stash-clear-interactive'
|
||||
alias gsl='git stash list'
|
||||
alias gsd='git stash show --patch --stat'
|
||||
alias gsp='git stash pop'
|
||||
alias gsr='git-stash-recover'
|
||||
alias gss='git stash save --include-untracked'
|
||||
alias gsS='git stash save --patch --no-keep-index'
|
||||
alias gsw='git stash save --include-untracked --keep-index'
|
||||
alias gsu='git stash show --patch | git apply --reverse'
|
||||
|
||||
# Submodule (S)
|
||||
alias gS='git submodule'
|
||||
alias gSa='git submodule add'
|
||||
alias gSf='git submodule foreach'
|
||||
alias gSi='git submodule init'
|
||||
alias gSI='git submodule update --init --recursive'
|
||||
alias gSl='git submodule status'
|
||||
alias gSm='git-submodule-move'
|
||||
alias gSs='git submodule sync'
|
||||
alias gSu='git submodule foreach git pull origin master'
|
||||
alias gSx='git-submodule-remove'
|
||||
|
||||
# Tag (t)
|
||||
alias gt='git tag'
|
||||
alias gts='git tag --sign'
|
||||
alias gtv='git verify-tag'
|
||||
alias gtx='git tag --delete'
|
||||
|
||||
# Working tree (w)
|
||||
alias gws='git status --short'
|
||||
alias gwS='git status'
|
||||
alias gwd='git diff --no-ext-diff'
|
||||
alias gwD='git diff --no-ext-diff --word-diff'
|
||||
alias gwr='git reset --soft'
|
||||
alias gwR='git reset --hard'
|
||||
alias gwc='git clean --dry-run'
|
||||
alias gwC='git clean -d --force'
|
||||
alias gwx='git rm -r'
|
||||
alias gwX='git rm -rf'
|
||||
|
||||
# Misc
|
||||
alias g..='cd "$(git-root || print .)"'
|
|
@ -1,19 +0,0 @@
|
|||
history-substring-search
|
||||
========================
|
||||
|
||||
Allows for fish-like searching of history with UP and DOWN.
|
||||
|
||||
![example][example]
|
||||
|
||||
If you use
|
||||
[syntax-highlighting](https://github.com/zimfw/zimfw/tree/master/modules/syntax-highlighting),
|
||||
make sure you place 'syntax-highlighting' before 'history-substring-search' on
|
||||
the second line of `zmodules` in your `.zimrc`.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Contributions should be submitted [upstream to
|
||||
zsh-history-substring-search](https://github.com/zsh-users/zsh-history-substring-search).
|
||||
|
||||
[example]: https://i.eriner.me/zim_history-substring-search.gif
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 933733e86724a018cb98cb8f514fc3d323461f74
|
|
@ -1,15 +0,0 @@
|
|||
#
|
||||
# Enable searching history with substrings
|
||||
#
|
||||
|
||||
# Source script
|
||||
source ${0:h}/external/zsh-history-substring-search.zsh || return 1
|
||||
|
||||
# Binding ^[[A/^[[B manually mean up/down works with history-substring-search both before and after zle-line-init
|
||||
bindkey '^[[A' history-substring-search-up
|
||||
bindkey '^[[B' history-substring-search-down
|
||||
|
||||
# Bind up and down keys
|
||||
zmodload -F zsh/terminfo +p:terminfo
|
||||
bindkey "${terminfo[kcuu1]}" history-substring-search-up
|
||||
bindkey "${terminfo[kcud1]}" history-substring-search-down
|
|
@ -1,22 +0,0 @@
|
|||
history
|
||||
=======
|
||||
|
||||
Sets sane history options.
|
||||
|
||||
The history is set to be saved in the `${ZDOTDIR:-${HOME}}/.zhistory` file.
|
||||
|
||||
Zsh options
|
||||
-----------
|
||||
|
||||
* `BANG_HIST` performs csh-style '!' expansion.
|
||||
* `SHARE_HISTORY` causes all terminals to share the same history 'session'.
|
||||
* `HIST_IGNORE_DUPS` does not enter immediate duplicates into the history.
|
||||
* `HIST_IGNORE_ALL_DUPS` removes older command from the history if a duplicate is to be added.
|
||||
* `HIST_IGNORE_SPACE` removes commands from the history that begin with a space.
|
||||
* `HIST_SAVE_NO_DUPS` ommits older commands that duplicate newer ones when saving.
|
||||
* `HIST_VERIFY` doesn't execute the command directly upon history expansion.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
* `history-stat` lists the 10 most used commands
|
|
@ -1,40 +0,0 @@
|
|||
#
|
||||
# Configures history options
|
||||
#
|
||||
|
||||
# The file to save the history in.
|
||||
HISTFILE="${ZDOTDIR:-${HOME}}/.zhistory"
|
||||
|
||||
# The maximum number of events stored in the internal history list and in the history file.
|
||||
HISTSIZE=10000
|
||||
SAVEHIST=10000
|
||||
|
||||
# Perform textual history expansion, csh-style, treating the character ‘!’ specially.
|
||||
setopt BANG_HIST
|
||||
|
||||
# This option both imports new commands from the history file, and also causes your
|
||||
# typed commands to be appended to the history file (like specifying INC_APPEND_HISTORY).
|
||||
# The history lines are also output with timestamps ala EXTENDED_HISTORY.
|
||||
setopt SHARE_HISTORY
|
||||
|
||||
# Do not enter command lines into the history list if they are duplicates of the previous event.
|
||||
setopt HIST_IGNORE_DUPS
|
||||
|
||||
# If a new command line being added to the history list duplicates an older one,
|
||||
# the older command is removed from the list (even if it is not the previous event).
|
||||
setopt HIST_IGNORE_ALL_DUPS
|
||||
|
||||
# Remove command lines from the history list when the first character on the
|
||||
# line is a space, or when one of the expanded aliases contains a leading space.
|
||||
setopt HIST_IGNORE_SPACE
|
||||
|
||||
# When writing out the history file, older commands that duplicate newer ones are omitted.
|
||||
setopt HIST_SAVE_NO_DUPS
|
||||
|
||||
# Whenever the user enters a line with history expansion, don't execute the line directly;
|
||||
# instead, perform history expansion and reload the line into the editing buffer.
|
||||
setopt HIST_VERIFY
|
||||
|
||||
|
||||
# Lists the ten most used commands.
|
||||
alias history-stat="fc -ln 0 | awk '{print \$1}' | sort | uniq -c | sort -nr | head"
|
|
@ -1,11 +0,0 @@
|
|||
input
|
||||
=====
|
||||
|
||||
Applies correct bindkeys for input events.
|
||||
|
||||
Without this module, you may experience oddities in how Zsh interprets input.
|
||||
For example, pressing LEFT and then the DELETE key may capitalize characters
|
||||
rather than delete them.
|
||||
|
||||
This module also provides double-dot parent directory expansion.
|
||||
It can be enabled by uncommenting `zdouble_dot_expand='true'` in your `.zimrc`.
|
|
@ -1,106 +0,0 @@
|
|||
#
|
||||
# Editor and input char assignment
|
||||
#
|
||||
|
||||
|
||||
# Return if requirements are not found.
|
||||
if [[ ${TERM} == 'dumb' ]]; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# Use human-friendly identifiers.
|
||||
zmodload -F zsh/terminfo +b:echoti +p:terminfo
|
||||
typeset -gA key_info
|
||||
key_info=(
|
||||
'Control' '\C-'
|
||||
'ControlLeft' '\e[1;5D \e[5D \e\e[D \eOd \eOD'
|
||||
'ControlRight' '\e[1;5C \e[5C \e\e[C \eOc \eOC'
|
||||
'Escape' '\e'
|
||||
'Meta' '\M-'
|
||||
'Backspace' "${terminfo[kbs]}"
|
||||
'BackTab' "${terminfo[kcbt]}"
|
||||
'Left' "${terminfo[kcub1]}"
|
||||
'Down' "${terminfo[kcud1]}"
|
||||
'Right' "${terminfo[kcuf1]}"
|
||||
'Up' "${terminfo[kcuu1]}"
|
||||
'Delete' "${terminfo[kdch1]}"
|
||||
'End' "${terminfo[kend]}"
|
||||
'F1' "${terminfo[kf1]}"
|
||||
'F2' "${terminfo[kf2]}"
|
||||
'F3' "${terminfo[kf3]}"
|
||||
'F4' "${terminfo[kf4]}"
|
||||
'F5' "${terminfo[kf5]}"
|
||||
'F6' "${terminfo[kf6]}"
|
||||
'F7' "${terminfo[kf7]}"
|
||||
'F8' "${terminfo[kf8]}"
|
||||
'F9' "${terminfo[kf9]}"
|
||||
'F10' "${terminfo[kf10]}"
|
||||
'F11' "${terminfo[kf11]}"
|
||||
'F12' "${terminfo[kf12]}"
|
||||
'Home' "${terminfo[khome]}"
|
||||
'Insert' "${terminfo[kich1]}"
|
||||
'PageDown' "${terminfo[knp]}"
|
||||
'PageUp' "${terminfo[kpp]}"
|
||||
)
|
||||
|
||||
# Bind the keys
|
||||
|
||||
local key
|
||||
for key (${(s: :)key_info[ControlLeft]}) bindkey ${key} backward-word
|
||||
for key (${(s: :)key_info[ControlRight]}) bindkey ${key} forward-word
|
||||
|
||||
[[ -n ${key_info[Home]} ]] && bindkey ${key_info[Home]} beginning-of-line
|
||||
[[ -n ${key_info[End]} ]] && bindkey ${key_info[End]} end-of-line
|
||||
|
||||
[[ -n ${key_info[PageUp]} ]] && bindkey ${key_info[PageUp]} up-line-or-history
|
||||
[[ -n ${key_info[PageDown]} ]] && bindkey ${key_info[PageDown]} down-line-or-history
|
||||
|
||||
[[ -n ${key_info[Insert]} ]] && bindkey ${key_info[Insert]} overwrite-mode
|
||||
|
||||
if [[ ${zdouble_dot_expand} == 'true' ]]; then
|
||||
double-dot-expand() {
|
||||
if [[ ${LBUFFER} == *.. ]]; then
|
||||
LBUFFER+='/..'
|
||||
else
|
||||
LBUFFER+='.'
|
||||
fi
|
||||
}
|
||||
zle -N double-dot-expand
|
||||
bindkey '.' double-dot-expand
|
||||
fi
|
||||
|
||||
[[ -n ${key_info[Backspace]} ]] && bindkey ${key_info[Backspace]} backward-delete-char
|
||||
[[ -n ${key_info[Delete]} ]] && bindkey ${key_info[Delete]} delete-char
|
||||
|
||||
[[ -n ${key_info[Left]} ]] && bindkey ${key_info[Left]} backward-char
|
||||
[[ -n ${key_info[Right]} ]] && bindkey ${key_info[Right]} forward-char
|
||||
|
||||
# Expandpace.
|
||||
bindkey ' ' magic-space
|
||||
|
||||
# Clear
|
||||
bindkey "${key_info[Control]}L" clear-screen
|
||||
|
||||
# Bind Shift + Tab to go to the previous menu item.
|
||||
[[ -n ${key_info[BackTab]} ]] && bindkey ${key_info[BackTab]} reverse-menu-complete
|
||||
|
||||
autoload -Uz is-at-least && if ! is-at-least 5.3; then
|
||||
# Redisplay after completing, and avoid blank prompt after <Tab><Tab><Ctrl-C>
|
||||
expand-or-complete-with-redisplay() {
|
||||
print -Pn '...'
|
||||
zle expand-or-complete
|
||||
zle redisplay
|
||||
}
|
||||
zle -N expand-or-complete-with-redisplay
|
||||
bindkey "${key_info[Control]}I" expand-or-complete-with-redisplay
|
||||
fi
|
||||
|
||||
# Put into application mode and validate ${terminfo}
|
||||
zle-line-init() {
|
||||
(( ${+terminfo[smkx]} )) && echoti smkx
|
||||
}
|
||||
zle-line-finish() {
|
||||
(( ${+terminfo[rmkx]} )) && echoti rmkx
|
||||
}
|
||||
zle -N zle-line-init
|
||||
zle -N zle-line-finish
|
|
@ -1,61 +0,0 @@
|
|||
pacman
|
||||
======
|
||||
|
||||
Adds aliases for the pacman package manager.
|
||||
|
||||
Also includes optional helper(s).
|
||||
|
||||
.zimrc Configuration
|
||||
-------------
|
||||
* `zpacman_frontend='helper_here'` Set helper_here to a wrapper if applicable (powerpill, pacmatic, etc).
|
||||
* `zpacman_helper=(aur)` add/remove any helper scripts to be loaded here.
|
||||
|
||||
Helpers
|
||||
-------
|
||||
|
||||
### aur
|
||||
|
||||
provides simple AUR helper aliases.
|
||||
|
||||
* `aurb package_name` clone the package from the AUR, build, and install.
|
||||
* `aurd package_name` clone the package from the AUR, but do not build.
|
||||
* `auru` run inside a directory created with `aurb`, this will update, build, and install a package.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### Build
|
||||
|
||||
* `pacb` build package in the current directory, cleanup, and install.
|
||||
|
||||
### Install
|
||||
|
||||
* `paci` install, sync, and upgrade packages.
|
||||
* `pacu` install, sync, and upgrade packages (forcibly refresh package list).
|
||||
* `pacU` install packages from pkg file.
|
||||
* `pacd` install all packages in current directory.
|
||||
|
||||
### Remove
|
||||
|
||||
* `pacr` remove package and unneeded dependencies.
|
||||
* `pacrm` remove package, unneded dependencies, and configuration files.
|
||||
|
||||
### Query
|
||||
|
||||
* `pacq` query package information from remote repository
|
||||
* `pacQ` query package information from local repository
|
||||
|
||||
### Search
|
||||
|
||||
* `pacs` search for package in the remote repository
|
||||
* `pacS` search for package in the local repository
|
||||
|
||||
### Orphans
|
||||
|
||||
* `pacol` list orphan packages
|
||||
* `pacor` remove all orphan packages
|
||||
|
||||
### Ownership
|
||||
|
||||
* `pacown` list all files provided by a given package
|
||||
* `pacblame` show package(s) that own a specified file
|
|
@ -1,3 +0,0 @@
|
|||
#compdef aurman packer wrapaur yaourt
|
||||
|
||||
service=pacman; _pacman
|
|
@ -1,20 +0,0 @@
|
|||
#
|
||||
# AUR aliases
|
||||
#
|
||||
|
||||
# download and build AUR package
|
||||
aurb() {
|
||||
git clone https://aur.archlinux.org/${1}.git && cd ${1} && makepkg --clean --install --syncdeps
|
||||
}
|
||||
|
||||
# only download aur package; do not build
|
||||
aurd() {
|
||||
git clone https://aur.archlinux.org/${1}.git
|
||||
}
|
||||
|
||||
# remove old package, rebuild, and install.
|
||||
#NOTE: this is will remove any unstashed/uncommitted changes.
|
||||
# due to how makepkg will update the PKGBUILD, a git pull alone will not suffice.
|
||||
auru() {
|
||||
git reset HEAD --hard && git pull && makepkg --clean --force --install --syncdeps --cleanbuild
|
||||
}
|
|
@ -1,135 +0,0 @@
|
|||
#
|
||||
# Pacman aliases
|
||||
#
|
||||
|
||||
# ${zpacman_frontend} is provided by either .zimrc or (if not set) init.zsh
|
||||
# The zpacman_frontend is _only_ used for package installs.
|
||||
|
||||
#
|
||||
# Setup
|
||||
#
|
||||
|
||||
# ensure pacman is available
|
||||
if (( ! ${+commands[pacman]} )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
local zpacman_frontend_priv helper
|
||||
|
||||
if (( ! ${+zpacman_frontend} )); then
|
||||
zpacman_frontend='pacman'
|
||||
zpacman_frontend_priv='sudo pacman'
|
||||
elif (( ! ${+commands[${zpacman_frontend}]} )); then
|
||||
print "pacman frontend \"${zpacman_frontend}\" is invalid or not installed. Reverting to \"pacman\".
|
||||
You can fix this error by editing the 'zpacman_frontend' variable in your .zimrc" >&2
|
||||
zpacman_frontend='pacman'
|
||||
zpacman_frontend_priv='sudo pacman'
|
||||
elif [[ ${zpacman_frontend} == ("yaourt"|"pacaur"|"yay"|"pikaur") ]]; then
|
||||
# those AUR helpers handle SUID themselves
|
||||
zpacman_frontend_priv="${zpacman_frontend}"
|
||||
else
|
||||
zpacman_frontend_priv="sudo ${zpacman_frontend}"
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# General
|
||||
#
|
||||
|
||||
alias pac=${zpacman_frontend}
|
||||
|
||||
#
|
||||
# Build
|
||||
#
|
||||
|
||||
# build package in current directory, cleanup, and install
|
||||
alias pacb='makepkg -sci'
|
||||
|
||||
#
|
||||
# Install
|
||||
#
|
||||
|
||||
#NOTE: Installing/upgrading individual packages is NOT supported. Sync and upgrade ALL on install.
|
||||
|
||||
# install, sync, and upgrade packages
|
||||
alias paci="${zpacman_frontend_priv} -Syu"
|
||||
|
||||
# install packages without syncing
|
||||
alias pacI="${zpacman_frontend_priv} -S"
|
||||
|
||||
# install, sync, and upgrade packages (forcibly refresh package lists)
|
||||
alias pacu="${zpacman_frontend_priv} -Syyu"
|
||||
|
||||
# install packages by filename
|
||||
alias pacU="${zpacman_frontend_priv} -U"
|
||||
|
||||
# install all packages in current directory
|
||||
alias pacd="${zpacman_frontend_priv} -U *.pkg.*"
|
||||
|
||||
|
||||
#
|
||||
# Remove
|
||||
#
|
||||
|
||||
# remove package and unneeded dependencies
|
||||
alias pacr="${zpacman_frontend_priv} -R"
|
||||
|
||||
# remove package, unneeded dependencies, and configuration files
|
||||
alias pacrm="${zpacman_frontend_priv} -Rns"
|
||||
|
||||
|
||||
#
|
||||
# Query
|
||||
#
|
||||
|
||||
# query package information from the remote repository
|
||||
alias pacq="${zpacman_frontend} -Si"
|
||||
|
||||
# query package information from the local repository
|
||||
alias pacQ="${zpacman_frontend} -Qi"
|
||||
|
||||
|
||||
#
|
||||
# Search
|
||||
#
|
||||
|
||||
# search for package in the remote repository
|
||||
alias pacs="${zpacman_frontend} -Ss"
|
||||
|
||||
# search for the package in the local repository
|
||||
alias pacS="${zpacman_frontend} -Qs"
|
||||
|
||||
|
||||
#
|
||||
# Orphans
|
||||
#
|
||||
|
||||
# list orphan packages
|
||||
alias pacol="${zpacman_frontend} -Qdt"
|
||||
|
||||
# remove orphan packages
|
||||
alias pacor="${zpacman_frontend_priv} -Rns \$(pacman -Qtdq)"
|
||||
|
||||
|
||||
#
|
||||
# Ownership
|
||||
#
|
||||
|
||||
# list all files that belong to a package
|
||||
alias pacown="${zpacman_frontend} -Ql"
|
||||
|
||||
# show package(s) owning the specified file
|
||||
alias pacblame="${zpacman_frontend} -Qo"
|
||||
|
||||
#
|
||||
# Helpers
|
||||
#
|
||||
|
||||
# source helper functions/aliases
|
||||
for helper in ${zpacman_helper}; do
|
||||
if [[ -s ${0:h}/helper_${helper}.zsh ]]; then
|
||||
source ${0:h}/helper_${helper}.zsh
|
||||
else
|
||||
print "no such helper script \"helper_${helper}.zsh\"" >&2
|
||||
fi
|
||||
done
|
|
@ -1,15 +0,0 @@
|
|||
prompt
|
||||
======
|
||||
|
||||
Initializes and provides customizable prompt themes.
|
||||
|
||||
Images of various prompt themes can be found on the [wiki](https://github.com/zimfw/zimfw/wiki/Themes).
|
||||
|
||||
A list of available prompts can be found by running `prompt -l`.
|
||||
|
||||
To test a prompt, simply run `prompt prompt_name_here`.
|
||||
|
||||
.zimrc Configuration
|
||||
--------------------
|
||||
|
||||
* `zprompt_theme='eriner'` change 'eriner' to the name of your desired prompt. This will set it as you default prompt.
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 3cf61b240d0bb0e3d1c517d2324534ddbf3614e8
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 9c80396021a8106bfaeade9a1ea51b85152e951d
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 7aade5fca2acae3f10e260d0c076af6356da9dc6
|
|
@ -1 +0,0 @@
|
|||
../external-themes/pure/async.zsh
|
|
@ -1 +0,0 @@
|
|||
../external-themes/liquidprompt/liquidprompt
|
|
@ -1 +0,0 @@
|
|||
../themes/eriner.zsh-theme
|
|
@ -1 +0,0 @@
|
|||
../themes/gitster.zsh-theme
|
|
@ -1 +0,0 @@
|
|||
../external-themes/lean/prompt_lean_setup
|
|
@ -1,12 +0,0 @@
|
|||
prompt_liquidprompt_setup() {
|
||||
autoload -Uz ex-liquidprompt
|
||||
ext-liquidprompt
|
||||
}
|
||||
|
||||
prompt_liquidprompt_preview() {
|
||||
_lp_set_prompt
|
||||
prompt_preview_theme liquidprompt
|
||||
prompt_off
|
||||
}
|
||||
|
||||
prompt_liquidprompt_setup "$@"
|
|
@ -1 +0,0 @@
|
|||
../themes/magicmace.zsh-theme
|
|
@ -1 +0,0 @@
|
|||
../themes/minimal.zsh-theme
|
|
@ -1 +0,0 @@
|
|||
../external-themes/pure/pure.zsh
|
|
@ -1 +0,0 @@
|
|||
../themes/steeef.zsh-theme
|
|
@ -1,10 +0,0 @@
|
|||
# shortens the pwd for use in prompt
|
||||
|
||||
local current_dir="${${1:-${PWD}}/#${HOME}/~}"
|
||||
|
||||
# if we aren't in ~
|
||||
if [[ ${current_dir} != '~' ]]; then
|
||||
current_dir="${${${${(@j:/:M)${(@s:/:)current_dir}##.#?}:h}%/}//\%/%%}/${${current_dir:t}//\%/%%}"
|
||||
fi
|
||||
|
||||
print ${current_dir}
|
|
@ -1,8 +0,0 @@
|
|||
#
|
||||
# load user-defined prompt
|
||||
#
|
||||
|
||||
if [[ ! ${TERM} == (linux|*bsd*|dumb) ]] && (( ${+zprompt_theme} )); then
|
||||
autoload -Uz promptinit && promptinit
|
||||
prompt ${(ps: :)${zprompt_theme}}
|
||||
fi
|
|
@ -1,140 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Eriner's Theme - fork of agnoster
|
||||
# A Powerline-inspired theme for ZSH
|
||||
#
|
||||
# In order for this theme to render correctly, a font with Powerline symbols is
|
||||
# required. A simple way to install a font with Powerline symbols is to follow
|
||||
# the instructions here: https://github.com/powerline/fonts#installation
|
||||
#
|
||||
# The aim of this theme is to only show you *relevant* information. Like most
|
||||
# prompts, it will only show git information when in a git working directory.
|
||||
# However, it goes a step further: everything from the current user and
|
||||
# hostname to whether the last call exited with an error to whether background
|
||||
# jobs are running in this shell will all be displayed automatically when
|
||||
# appropriate.
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
prompt_eriner_help () {
|
||||
cat <<EOH
|
||||
This prompt is color-scheme-able. You can customize it using:
|
||||
|
||||
prompt eriner [status_color] [pwd_color] [git_clean_color] [git_dirty_color]
|
||||
|
||||
where the parameters are the background colors for each segment. The default
|
||||
values are black, cyan, green, and yellow.
|
||||
|
||||
In order for this prompt to render correctly, a font with Powerline symbols is
|
||||
required. A simple way to install a font with Powerline symbols is to follow
|
||||
the instructions here: https://github.com/powerline/fonts#installation
|
||||
EOH
|
||||
}
|
||||
|
||||
prompt_eriner_main() {
|
||||
local prompt_eriner_retval=${?}
|
||||
local prompt_eriner_color1=${1:-black}
|
||||
local prompt_eriner_color2=${2:-cyan}
|
||||
|
||||
### Segment drawing
|
||||
# Utility functions to make it easy and re-usable to draw segmented prompts.
|
||||
|
||||
local prompt_eriner_bg
|
||||
|
||||
# Begin a segment. Takes two arguments, background color and contents of the
|
||||
# new segment.
|
||||
prompt_eriner_segment() {
|
||||
print -n "%K{${1}}"
|
||||
[[ -n ${prompt_eriner_bg} ]] && print -n "%F{${prompt_eriner_bg}}"
|
||||
print -n "${2}"
|
||||
prompt_eriner_bg=${1}
|
||||
}
|
||||
|
||||
prompt_eriner_standout_segment() {
|
||||
print -n "%S%F{${1}}"
|
||||
[[ -n ${prompt_eriner_bg} ]] && print -n "%K{${prompt_eriner_bg}}%k"
|
||||
print -n "${2}%s"
|
||||
prompt_eriner_bg=${1}
|
||||
}
|
||||
|
||||
# End the prompt, closing last segment.
|
||||
prompt_eriner_end() {
|
||||
print -n "%k%F{${prompt_eriner_bg}}%f "
|
||||
}
|
||||
|
||||
### Prompt components
|
||||
# Each component will draw itself, or hide itself if no information needs to
|
||||
# be shown.
|
||||
|
||||
# Status: Was there an error? Am I root? Are there background jobs? Ranger
|
||||
# spawned shell? Who and where am I (user@hostname)?
|
||||
prompt_eriner_status() {
|
||||
local segment=''
|
||||
(( prompt_eriner_retval )) && segment+=' %F{red}✘'
|
||||
(( UID == 0 )) && segment+=' %F{yellow}⚡'
|
||||
(( $(jobs -l | wc -l) )) && segment+=' %F{cyan}⚙'
|
||||
(( RANGER_LEVEL )) && segment+=' %F{cyan}r'
|
||||
if [[ ${USER} != ${DEFAULT_USER} || -n ${SSH_CLIENT} ]]; then
|
||||
segment+=" %F{%(!.yellow.default)}${USER}@%m"
|
||||
fi
|
||||
if [[ -n ${segment} ]]; then
|
||||
prompt_eriner_segment ${prompt_eriner_color1} "${segment} "
|
||||
fi
|
||||
}
|
||||
|
||||
# Pwd: current working directory.
|
||||
prompt_eriner_pwd() {
|
||||
prompt_eriner_standout_segment ${prompt_eriner_color2} " $(short_pwd) "
|
||||
}
|
||||
|
||||
# Git: branch/detached head, dirty status.
|
||||
prompt_eriner_git() {
|
||||
if [[ -n ${git_info} ]]; then
|
||||
local indicator
|
||||
[[ ${git_info[color]} == yellow ]] && indicator=' ±'
|
||||
prompt_eriner_standout_segment ${git_info[color]} " ${(e)git_info[prompt]}${indicator} "
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_eriner_status
|
||||
prompt_eriner_pwd
|
||||
prompt_eriner_git
|
||||
prompt_eriner_end
|
||||
}
|
||||
|
||||
prompt_eriner_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_eriner_setup() {
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_eriner_precmd
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
local prompt_eriner_color3=${3:-green}
|
||||
local prompt_eriner_color4=${4:-yellow}
|
||||
|
||||
zstyle ':zim:git-info:branch' format ' %b'
|
||||
zstyle ':zim:git-info:commit' format '➦ %c'
|
||||
zstyle ':zim:git-info:action' format ' (%s)'
|
||||
zstyle ':zim:git-info:clean' format ${prompt_eriner_color3}
|
||||
zstyle ':zim:git-info:dirty' format ${prompt_eriner_color4}
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '%b%c%s' \
|
||||
'color' '%C%D'
|
||||
|
||||
PS1="\$(prompt_eriner_main ${@:1:2})"
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_eriner_preview () {
|
||||
if (( ${#} )); then
|
||||
prompt_preview_theme eriner "${@}"
|
||||
else
|
||||
prompt_preview_theme eriner
|
||||
print
|
||||
prompt_preview_theme eriner black blue green yellow
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_eriner_setup "${@}"
|
|
@ -1,40 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# Gitster theme
|
||||
# https://github.com/shashankmehta/dotfiles/blob/master/thesetup/zsh/.oh-my-zsh/custom/themes/gitster.zsh-theme
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
prompt_gitster_pwd() {
|
||||
prompt_short_dir=$(short_pwd)
|
||||
git_root=$(command git rev-parse --show-toplevel 2> /dev/null) && prompt_short_dir=${prompt_short_dir#${$(short_pwd $git_root):h}/}
|
||||
print -n "%F{white}${prompt_short_dir}"
|
||||
}
|
||||
|
||||
prompt_gitster_git() {
|
||||
[[ -n ${git_info} ]] && print -n "${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_gitster_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_gitster_setup() {
|
||||
local prompt_gitster_status='%(?:%F{green}:%F{red})➜ '
|
||||
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_gitster_precmd
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:clean' format '%F{green}✓'
|
||||
zstyle ':zim:git-info:dirty' format '%F{yellow}✗'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' ' %F{cyan}%b%c %C%D'
|
||||
|
||||
PS1="${prompt_gitster_status}\$(prompt_gitster_pwd)\$(prompt_gitster_git)%f "
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_gitster_setup "${@}"
|
|
@ -1,72 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# magicmace theme
|
||||
# Ideas and code taken from:
|
||||
# xero's zsh prompt <http://code.xero.nu/dotfiles>
|
||||
# eriner's eriner prompt <https://github.com/zimfw/zimfw/blob/master/modules/prompt/themes/eriner.zsh-theme>
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
# Global variables
|
||||
function {
|
||||
COLOR_ROOT="%F{red}"
|
||||
COLOR_USER="%F{cyan}"
|
||||
COLOR_NORMAL="%F{white}"
|
||||
COLOR_ERROR="%F{red}"
|
||||
|
||||
if (( ${EUID} )); then
|
||||
COLOR_USER_LEVEL=${COLOR_USER}
|
||||
else
|
||||
COLOR_USER_LEVEL=${COLOR_ROOT}
|
||||
fi
|
||||
}
|
||||
|
||||
# Status:
|
||||
# - was there an error?
|
||||
# - are there background jobs?
|
||||
# - are we in a ranger session?
|
||||
prompt_magicmace_status() {
|
||||
local symbols=""
|
||||
|
||||
(( ${RETVAL} )) && symbols+="${COLOR_ERROR}${RETVAL}${COLOR_NORMAL}" # $? for error.
|
||||
(( $(jobs -l | wc -l) > 0 )) && symbols+='b' # 'b' for background.
|
||||
(( ${RANGER_LEVEL} )) && symbols+='r' # 'r' for... you guessed it!
|
||||
|
||||
[[ -n ${symbols} ]] && print -n "─${COLOR_NORMAL}${symbols}${COLOR_USER_LEVEL}─"
|
||||
}
|
||||
|
||||
prompt_magicmace_git() {
|
||||
[[ -n ${git_info} ]] && print -n "${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_magicmace_precmd() {
|
||||
# While it would be apt to have this as a local variable in prompt_status(),
|
||||
# $? (returned value) and ${(%):-%?} ("The return status of the last command
|
||||
# executed just before the prompt") both change before executing the function.
|
||||
# Is this perhaps because prompt_status _is_ here?
|
||||
# We could also just set $? as an argument, and thus get our nifty local variable,
|
||||
# but that's stretching it, and makes the code harder to read.
|
||||
RETVAL=$?
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_magicmace_setup() {
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_magicmace_precmd
|
||||
autoload -Uz colors && colors
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c...'
|
||||
zstyle ':zim:git-info:dirty' format '*'
|
||||
zstyle ':zim:git-info:ahead' format '↑'
|
||||
zstyle ':zim:git-info:behind' format '↓'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '─[${COLOR_NORMAL}%b%c%D%A%B${COLOR_USER_LEVEL}]'
|
||||
|
||||
# Call git directly, ignoring aliases under the same name.
|
||||
PS1='${COLOR_USER_LEVEL}$(prompt_magicmace_status)[${COLOR_NORMAL}$(short_pwd)${COLOR_USER_LEVEL}]$(prompt_magicmace_git)── ─%f '
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_magicmace_setup "${@}"
|
|
@ -1,88 +0,0 @@
|
|||
#
|
||||
# Minimal theme
|
||||
# https://github.com/S1cK94/minimal
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
# Global variables
|
||||
function {
|
||||
PROMPT_CHAR='❯'
|
||||
|
||||
ON_COLOR='%F{green}'
|
||||
OFF_COLOR='%f'
|
||||
ERR_COLOR='%F{red}'
|
||||
}
|
||||
|
||||
prompt_minimal_user() {
|
||||
print -n '%(!.${ON_COLOR}.${OFF_COLOR})${PROMPT_CHAR}'
|
||||
}
|
||||
|
||||
prompt_minimal_jobs() {
|
||||
print -n '%(1j.${ON_COLOR}.${OFF_COLOR})${PROMPT_CHAR}'
|
||||
}
|
||||
|
||||
prompt_minimal_vimode() {
|
||||
local color
|
||||
|
||||
case ${KEYMAP} in
|
||||
main|viins)
|
||||
color=${ON_COLOR}
|
||||
;;
|
||||
*)
|
||||
color=${OFF_COLOR}
|
||||
;;
|
||||
esac
|
||||
|
||||
print -n "${color}${PROMPT_CHAR}"
|
||||
}
|
||||
|
||||
prompt_minimal_status() {
|
||||
print -n '%(0?.${ON_COLOR}.${ERR_COLOR})${PROMPT_CHAR}'
|
||||
}
|
||||
|
||||
prompt_minimal_path() {
|
||||
local path_color='%F{244}'
|
||||
print -n "${path_color}${$(short_pwd)//\//%f\/${path_color}}%f"
|
||||
}
|
||||
|
||||
prompt_minimal_git() {
|
||||
if [[ -n ${git_info} ]]; then
|
||||
print -n " ${(e)git_info[color]}${(e)git_info[prompt]}"
|
||||
fi
|
||||
}
|
||||
|
||||
function zle-line-init zle-keymap-select {
|
||||
zle reset-prompt
|
||||
zle -R
|
||||
}
|
||||
|
||||
prompt_minimal_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_minimal_setup() {
|
||||
zle -N zle-line-init
|
||||
zle -N zle-keymap-select
|
||||
|
||||
autoload -Uz colors && colors
|
||||
autoload -Uz add-zsh-hook
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
add-zsh-hook precmd prompt_minimal_precmd
|
||||
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:dirty' format '${ERR_COLOR}'
|
||||
zstyle ':zim:git-info:diverged' format '${ERR_COLOR}'
|
||||
zstyle ':zim:git-info:behind' format '%F{11}'
|
||||
zstyle ':zim:git-info:ahead' format '${OFF_COLOR}'
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' '%b%c' \
|
||||
'color' '$(coalesce "%D" "%V" "%B" "%A" "${ON_COLOR}")'
|
||||
|
||||
PROMPT="$(prompt_minimal_user)$(prompt_minimal_jobs)\$(prompt_minimal_vimode)$(prompt_minimal_status)%f "
|
||||
RPROMPT='$(prompt_minimal_path)$(prompt_minimal_git)'
|
||||
}
|
||||
|
||||
prompt_minimal_setup "$@"
|
|
@ -1,116 +0,0 @@
|
|||
# vim:et sts=2 sw=2 ft=zsh
|
||||
#
|
||||
# A customizable version of the steeef theme from
|
||||
# https://github.com/robbyrussell/oh-my-zsh/blob/master/themes/steeef.zsh-theme
|
||||
#
|
||||
# Requires the `git-info` zmodule to be included in the .zimrc file.
|
||||
|
||||
prompt_steeef_help () {
|
||||
cat <<EOH
|
||||
This prompt can be customized with:
|
||||
|
||||
prompt steeef [username_color] [hostname_color] [pwd_color] [branch_color]
|
||||
[unindexed_color] [unindexed_indicator]
|
||||
[indexed_color] [indexed_indicator]
|
||||
[untracked_color] [untracked_indicator]
|
||||
[stashed_color] [stashed_indicator]
|
||||
|
||||
The default values for each parameter, for 256-color terminals (or otherwise)
|
||||
are the following:
|
||||
|
||||
1. username color: 135 (or magenta)
|
||||
2. hostname color: 166 (or yellow)
|
||||
3. current working directory color: 118 (or green)
|
||||
4. git branch name color: 81 (or cyan)
|
||||
5. git unindexed color: 166 (or yellow)
|
||||
6. git unindexed indicator: ●
|
||||
7. git indexed color: 118 (or green)
|
||||
8. git indexed indicator: ●
|
||||
9. git untracked color: 161 (or red)
|
||||
10. git untracked indicator: ●
|
||||
|
||||
The git stashed color and indicator are not defined by default, and will not be
|
||||
shown unless defined.
|
||||
EOH
|
||||
}
|
||||
|
||||
prompt_steeef_git() {
|
||||
[[ -n ${git_info} ]] && print -n " ${(e)git_info[prompt]}"
|
||||
}
|
||||
|
||||
prompt_steeef_virtualenv() {
|
||||
[[ -n ${VIRTUAL_ENV} ]] && print -n " (%F{blue}${VIRTUAL_ENV:t}%f)"
|
||||
}
|
||||
|
||||
prompt_steeef_precmd() {
|
||||
(( ${+functions[git-info]} )) && git-info
|
||||
}
|
||||
|
||||
prompt_steeef_setup() {
|
||||
[[ -n ${VIRTUAL_ENV} ]] && export VIRTUAL_ENV_DISABLE_PROMPT=1
|
||||
|
||||
local col_user
|
||||
local col_host
|
||||
local col_pwd
|
||||
local col_brnch
|
||||
local col_unidx
|
||||
local col_idx
|
||||
local col_untrk
|
||||
# use extended color palette if available
|
||||
if (( terminfo[colors] >= 256 )); then
|
||||
col_user="%F{${1:-135}}"
|
||||
col_host="%F{${2:-166}}"
|
||||
col_pwd="%F{${3:-118}}"
|
||||
col_brnch="%F{${4:-81}}"
|
||||
col_unidx="%F{${5:-166}}"
|
||||
col_idx="%F{${7:-118}}"
|
||||
col_untrk="%F{${9:-161}}"
|
||||
else
|
||||
col_user="%F{${1:-magenta}}"
|
||||
col_host="%F{${2:-yellow}}"
|
||||
col_pwd="%F{${3:-green}}"
|
||||
col_brnch="%F{${4:-cyan}}"
|
||||
col_unidx="%F{${5:-yellow}}"
|
||||
col_idx="%F{${7:-green}}"
|
||||
col_untrk="%F{${9:-red}}"
|
||||
fi
|
||||
local ind_unidx=${6:-●}
|
||||
local ind_idx=${8:-●}
|
||||
local ind_untrk=${10:-●}
|
||||
local col_stash=${11:+%F{${11}}}
|
||||
local ind_stash=${12}
|
||||
|
||||
autoload -Uz add-zsh-hook && add-zsh-hook precmd prompt_steeef_precmd
|
||||
|
||||
prompt_opts=(cr percent sp subst)
|
||||
|
||||
zstyle ':zim:git-info' verbose 'yes'
|
||||
zstyle ':zim:git-info:branch' format '%b'
|
||||
zstyle ':zim:git-info:commit' format '%c'
|
||||
zstyle ':zim:git-info:action' format "(${col_idx}%s%f)"
|
||||
zstyle ':zim:git-info:unindexed' format "${col_unidx}${ind_unidx}"
|
||||
zstyle ':zim:git-info:indexed' format "${col_idx}${ind_idx}"
|
||||
zstyle ':zim:git-info:untracked' format "${col_untrk}${ind_untrk}"
|
||||
if [[ -n ${ind_stash} ]]; then
|
||||
zstyle ':zim:git-info:stashed' format "${col_stash}${ind_stash}"
|
||||
fi
|
||||
zstyle ':zim:git-info:keys' format \
|
||||
'prompt' "(${col_brnch}%b%c%I%i%u%f%S%f)%s"
|
||||
|
||||
PS1="
|
||||
${col_user}%n%f at ${col_host}%m%f in ${col_pwd}%~%f\$(prompt_steeef_git)\$(prompt_steeef_virtualenv)
|
||||
%(!.#.$) "
|
||||
RPS1=''
|
||||
}
|
||||
|
||||
prompt_steeef_preview () {
|
||||
if (( ${#} )); then
|
||||
prompt_preview_theme steeef "${@}"
|
||||
else
|
||||
prompt_preview_theme steeef
|
||||
print
|
||||
prompt_preview_theme steeef magenta yellow green cyan magenta '!' green '+' red '?' yellow '$'
|
||||
fi
|
||||
}
|
||||
|
||||
prompt_steeef_setup "${@}"
|
|
@ -1,9 +0,0 @@
|
|||
ssh
|
||||
===
|
||||
|
||||
Provides a convenient way to load ssh-agent. This enables one-time login and caching of SSH credentials per session.
|
||||
|
||||
.zimrc Configuration
|
||||
--------------------
|
||||
|
||||
* `zssh_ids=(id_rsa)` add any identities (from ~/.ssh) to this list to have them loaded and cached on login.
|
|
@ -1,34 +0,0 @@
|
|||
#
|
||||
# sets up ssh-agent
|
||||
#
|
||||
|
||||
# don't do anything unless we can actually use ssh-agent
|
||||
if (( ! ${+commands[ssh-agent]} )); then
|
||||
return 1
|
||||
fi
|
||||
|
||||
ssh-add -l &>/dev/null
|
||||
if (( ? == 2 )); then
|
||||
# Unable to contact the authentication agent
|
||||
|
||||
# Load stored agent connection info
|
||||
local ssh_env="${HOME}/.ssh-agent"
|
||||
[[ -r ${ssh_env} ]] && source ${ssh_env} >/dev/null
|
||||
|
||||
ssh-add -l &>/dev/null
|
||||
if (( ? == 2 )); then
|
||||
# Start agent and store agent connection info
|
||||
(umask 066; ssh-agent >! ${ssh_env})
|
||||
source ${ssh_env} >/dev/null
|
||||
fi
|
||||
fi
|
||||
|
||||
# Load identities
|
||||
ssh-add -l &>/dev/null
|
||||
if (( ? == 1 )); then
|
||||
if (( ${#zssh_ids} > 0 )); then
|
||||
ssh-add "${HOME}/.ssh/${^zssh_ids[@]}" 2> /dev/null
|
||||
else
|
||||
ssh-add 2> /dev/null
|
||||
fi
|
||||
fi
|
|
@ -1,21 +0,0 @@
|
|||
syntax-highlighting
|
||||
===================
|
||||
|
||||
Adds fish shell-like [syntax highlighting](https://github.com/zsh-users/zsh-syntax-highlighting) to your shell.
|
||||
|
||||
![syntax-highlighting][syntax_highlighting]
|
||||
|
||||
If you are also using [history-substring-search](https://github.com/zimfw/zimfw/blob/master/modules/history-substring-search/README.md),
|
||||
ensure you have placed 'syntax-highlighting' before 'history-substring-search' on the second line of `zmodules` in your `.zimrc`.
|
||||
|
||||
.zimrc Configuration
|
||||
--------------------
|
||||
|
||||
* `zhighlighters=(main brackets cursor)` add any highlighters you want as described [here](https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md#zsh-syntax-highlighting--highlighters).
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Contributions should be submitted [upstream to zsh-syntax-highlighting](https://github.com/zsh-users/zsh-syntax-highlighting)
|
||||
|
||||
[syntax_highlighting]: https://i.eriner.me/zim_syntax-highlighting.gif
|
|
@ -1 +0,0 @@
|
|||
Subproject commit 434af7b11dd33641231f1b48b8432e68eb472e46
|
|
@ -1,8 +0,0 @@
|
|||
#
|
||||
# enables fish-shell like syntax highlighting
|
||||
#
|
||||
|
||||
# highlighters
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(${zhighlighters[@]})
|
||||
|
||||
source "${0:h}/external/zsh-syntax-highlighting.zsh" || return 1
|
|
@ -1,40 +0,0 @@
|
|||
utility
|
||||
=======
|
||||
|
||||
Utility aliases and functions.
|
||||
|
||||
Adds colour to `ls`, `grep` and `less`.
|
||||
|
||||
Aliases
|
||||
-------
|
||||
|
||||
### ls
|
||||
|
||||
* `ls` lists directories first (GNU only) and with colour (applies to all aliases below).
|
||||
* `ll` lists with long format and human-readable sizes (applies to all aliases below).
|
||||
* `l` lists all files.
|
||||
* `lm` lists all files using pager.
|
||||
* `lr` lists recursively.
|
||||
* `lx` lists sorted by extension (GNU only).
|
||||
* `lk` lists sorted by largest file size last.
|
||||
* `lt` lists sorted by newest modification time last.
|
||||
* `lc` lists sorted by newest status change (ctime) last.
|
||||
|
||||
### File downloads
|
||||
|
||||
* `get` is short for ( `aria2c` || `axel` || `wget` || `curl` ).
|
||||
|
||||
### Resource usage
|
||||
|
||||
* `df` reports file system disk usage with human-readable sizes.
|
||||
* `du` reports file disk usage with human-readable sizes.
|
||||
|
||||
### Condoms
|
||||
|
||||
* `chmod` changes file mode verbosely, not operating from `/` (GNU only).
|
||||
* `chown` changes file owner verbosely, not operating from `/` (GNU only).
|
||||
* `rm` uses `safe-rm` if available.
|
||||
|
||||
### Misc
|
||||
|
||||
* `mkcd` creates and changes to the given directory.
|
|
@ -1 +0,0 @@
|
|||
[[ -n ${1} ]] && mkdir -p ${1} && builtin cd ${1}
|
|
@ -1,111 +0,0 @@
|
|||
#
|
||||
# Utility Functions and Options
|
||||
#
|
||||
|
||||
#
|
||||
# Colours
|
||||
#
|
||||
|
||||
if (( terminfo[colors] >= 8 )); then
|
||||
|
||||
# ls Colours
|
||||
if (( ${+commands[dircolors]} )); then
|
||||
# GNU
|
||||
|
||||
(( ! ${+LS_COLORS} )) && if [[ -s ${HOME}/.dir_colors ]]; then
|
||||
eval "$(dircolors --sh ${HOME}/.dir_colors)"
|
||||
else
|
||||
export LS_COLORS='di=1;34:ln=35:so=32:pi=33:ex=31:bd=1;36:cd=1;33:su=30;41:sg=30;46:tw=30;42:ow=30;43'
|
||||
fi
|
||||
|
||||
alias ls='ls --group-directories-first --color=auto'
|
||||
else
|
||||
# BSD
|
||||
|
||||
(( ! ${+CLICOLOR} )) && export CLICOLOR=1
|
||||
(( ! ${+LSCOLORS} )) && export LSCOLORS='ExfxcxdxbxGxDxabagacad'
|
||||
|
||||
# stock OpenBSD ls does not support colors at all, but colorls does.
|
||||
if [[ ${OSTYPE} == openbsd* && ${+commands[colorls]} -ne 0 ]]; then
|
||||
alias ls='colorls'
|
||||
fi
|
||||
fi
|
||||
|
||||
# grep Colours
|
||||
(( ! ${+GREP_COLOR} )) && export GREP_COLOR='37;45' #BSD
|
||||
(( ! ${+GREP_COLORS} )) && export GREP_COLORS="mt=${GREP_COLOR}" #GNU
|
||||
if [[ ${OSTYPE} == openbsd* ]]; then
|
||||
(( ${+commands[ggrep]} )) && alias grep='ggrep --color=auto'
|
||||
else
|
||||
alias grep='grep --color=auto'
|
||||
fi
|
||||
|
||||
# less Colours
|
||||
if [[ ${PAGER} == 'less' ]]; then
|
||||
(( ! ${+LESS_TERMCAP_mb} )) && export LESS_TERMCAP_mb=$'\E[1;31m' # Begins blinking.
|
||||
(( ! ${+LESS_TERMCAP_md} )) && export LESS_TERMCAP_md=$'\E[1;31m' # Begins bold.
|
||||
(( ! ${+LESS_TERMCAP_me} )) && export LESS_TERMCAP_me=$'\E[0m' # Ends mode.
|
||||
(( ! ${+LESS_TERMCAP_se} )) && export LESS_TERMCAP_se=$'\E[0m' # Ends standout-mode.
|
||||
(( ! ${+LESS_TERMCAP_so} )) && export LESS_TERMCAP_so=$'\E[7m' # Begins standout-mode.
|
||||
(( ! ${+LESS_TERMCAP_ue} )) && export LESS_TERMCAP_ue=$'\E[0m' # Ends underline.
|
||||
(( ! ${+LESS_TERMCAP_us} )) && export LESS_TERMCAP_us=$'\E[1;32m' # Begins underline.
|
||||
fi
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# ls Aliases
|
||||
#
|
||||
|
||||
alias ll='ls -lh' # long format and human-readable sizes
|
||||
alias l='ll -A' # long format, all files
|
||||
[[ -n ${PAGER} ]] && alias lm="l | ${PAGER}" # long format, all files, use pager
|
||||
alias lr='ll -R' # long format, recursive
|
||||
alias lk='ll -Sr' # long format, largest file size last
|
||||
alias lt='ll -tr' # long format, newest modification time last
|
||||
alias lc='lt -c' # long format, newest status change (ctime) last
|
||||
|
||||
|
||||
#
|
||||
# File Downloads
|
||||
#
|
||||
|
||||
# order of preference: aria2c, axel, wget, curl. This order is derrived from speed based on personal tests.
|
||||
if (( ${+commands[aria2c]} )); then
|
||||
alias get='aria2c --max-connection-per-server=5 --continue'
|
||||
elif (( ${+commands[axel]} )); then
|
||||
alias get='axel --num-connections=5 --alternate'
|
||||
elif (( ${+commands[wget]} )); then
|
||||
alias get='wget --continue --progress=bar --timestamping'
|
||||
elif (( ${+commands[curl]} )); then
|
||||
alias get='curl --continue-at - --location --progress-bar --remote-name --remote-time'
|
||||
fi
|
||||
|
||||
|
||||
#
|
||||
# Resource Usage
|
||||
#
|
||||
|
||||
alias df='df -h'
|
||||
alias du='du -h'
|
||||
|
||||
|
||||
#
|
||||
# GNU only
|
||||
#
|
||||
|
||||
if (( ${+commands[dircolors]} )); then
|
||||
|
||||
alias lx='ll -X' # long format, sort by extension
|
||||
|
||||
# Always wear a condom
|
||||
alias chmod='chmod --preserve-root -v'
|
||||
alias chown='chown --preserve-root -v'
|
||||
fi
|
||||
|
||||
|
||||
# not aliasing rm -i, but if safe-rm is available, use condom.
|
||||
# if safe-rmdir is available, the OS is suse which has its own terrible 'safe-rm' which is not what we want
|
||||
if (( ${+commands[safe-rm]} && ! ${+commands[safe-rmdir]} )); then
|
||||
alias rm='safe-rm'
|
||||
fi
|
139
templates/zimrc
139
templates/zimrc
|
@ -1,96 +1,113 @@
|
|||
#################
|
||||
# CORE SETTINGS #
|
||||
#################
|
||||
################
|
||||
# ZIM SETTINGS #
|
||||
################
|
||||
|
||||
#
|
||||
# Zim settings
|
||||
#
|
||||
# Set input mode to 'emacs' (default) or 'vi'.
|
||||
#zstyle ':zim:input' mode 'vi'
|
||||
|
||||
# Select what modules you would like enabled.
|
||||
# The second line of modules may depend on options set by modules in the first
|
||||
# line. These dependencies are noted on the respective module's README.md.
|
||||
zmodules=(directory environment git git-info history input utility custom \
|
||||
prompt completion syntax-highlighting history-substring-search )
|
||||
# Select what modules you would like enabled. Modules are sourced in the order given.
|
||||
zstyle ':zim' modules \
|
||||
directory environment git git-info history input utility \
|
||||
eriner gitster magicmace s1ck94 steeef prompt \
|
||||
zsh-completions completion zsh-autosuggestions zsh-syntax-highlighting history-substring-search
|
||||
|
||||
# Modules setup configuration.
|
||||
# See ...
|
||||
zstyle ':zim:module' zsh-completions 'url' 'zsh-users/zsh-completions'
|
||||
zstyle ':zim:module' zsh-autosuggestions 'url' 'zsh-users/zsh-autosuggestions'
|
||||
zstyle ':zim:module' zsh-syntax-highlighting 'url' 'zsh-users/zsh-syntax-highlighting'
|
||||
|
||||
###################
|
||||
# MODULE SETTINGS #
|
||||
###################
|
||||
|
||||
#
|
||||
# Prompt
|
||||
# completion
|
||||
#
|
||||
|
||||
# Set your desired prompt here
|
||||
zprompt_theme='steeef'
|
||||
# Set a custom path for the completion dump file.
|
||||
# If none is provided, the default ${ZDOTDIR:-${HOME}}/.zcompdump is used.
|
||||
#zstyle ':zim:completion' dumpfile "${ZDOTDIR:-${HOME}}/.zcompdump-${ZSH_VERSION}"
|
||||
|
||||
#
|
||||
# Completion
|
||||
#
|
||||
|
||||
# Set an optional host-specific filename for the completion cache file. If none
|
||||
# is provided, the default '.zcompdump' is used.
|
||||
#zcompdump_file=".zcompdump-${HOST}-${ZSH_VERSION}"
|
||||
|
||||
#
|
||||
# Utility
|
||||
#
|
||||
|
||||
# Uncomment to enable spelling correction prompt for commands. See:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Options.html#Input_002fOutput
|
||||
#setopt CORRECT
|
||||
|
||||
# Set custom spelling correction prompt
|
||||
#SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
||||
|
||||
#
|
||||
# Environment
|
||||
# environment
|
||||
#
|
||||
|
||||
# Set the string below to the desired terminal title format string.
|
||||
# The terminal title is redrawn upon directory change, however, variables like
|
||||
# ${PWD} are only evaluated once. Use prompt expansion strings for dynamic data:
|
||||
# http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
|
||||
# The example below uses the following format: 'username@host:/current/directory'
|
||||
ztermtitle='%n@%m:%~'
|
||||
# The terminal title is redrawn upon directory change, however, variables like
|
||||
# ${PWD} are only evaluated once. Use prompt expansion strings for dynamic data.
|
||||
# See http://zsh.sourceforge.net/Doc/Release/Prompt-Expansion.html#Simple-Prompt-Escapes
|
||||
# For example, '%n@%m: %1~' corresponds to 'username@host: /current/directory'.
|
||||
#zstyle ':zim:environment' termtitle '%n@%m: %1~'
|
||||
|
||||
#
|
||||
# Input
|
||||
# history
|
||||
#
|
||||
|
||||
# Set to vi or emacs
|
||||
zinput_mode='emacs'
|
||||
|
||||
# Uncomment to enable double-dot expansion. This appends '../' to your input for
|
||||
# each '.' you type after an initial '..'
|
||||
#zdouble_dot_expand='true'
|
||||
# Save the history in a custom file path.
|
||||
# If none is provided, the default ${ZDOTDIR:-${HOME}}/.zhistory is used.
|
||||
#HISTFILE=${ZDOTDIR:-${HOME}}/.zsh_history
|
||||
|
||||
#
|
||||
# Syntax-Highlighting
|
||||
# input
|
||||
#
|
||||
|
||||
# This determines what highlighters will be used with the syntax-highlighting module.
|
||||
# Documentation of the highlighters can be found here:
|
||||
# https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
||||
# For (u)rxvt, termite and gnome-terminal users,
|
||||
# removing the 'cursor' highlighter will fix the disappearing cursor problem
|
||||
zhighlighters=(main brackets cursor)
|
||||
# Enable double-dot expansion.
|
||||
# This appends '../' to your input for each '.' you type after an initial '..'
|
||||
#zstyle ':zim:input' double-dot-expand yes
|
||||
|
||||
#
|
||||
# SSH
|
||||
# pacman
|
||||
#
|
||||
|
||||
# Load these ssh identities with the ssh module
|
||||
#zssh_ids=(id_rsa)
|
||||
# Set an optional pacman frontend.
|
||||
#zstyle ':zim:pacman' frontend 'powerpill'
|
||||
|
||||
# Load any helper scripts as defined here.
|
||||
#zstyle ':zim:pacman' helpers 'aur'
|
||||
|
||||
#
|
||||
# Pacman
|
||||
# prompt
|
||||
#
|
||||
|
||||
# Set (optional) pacman front-end.
|
||||
#zpacman_frontend='powerpill'
|
||||
# Set your desired prompt theme.
|
||||
zstyle ':zim:prompt' theme 'steeef'
|
||||
|
||||
# Load any helper scripts as defined here
|
||||
#zpacman_helper=(aur)
|
||||
#
|
||||
# ssh
|
||||
#
|
||||
|
||||
# Load these ssh identities with the ssh module.
|
||||
#zstyle ':zim:ssh' ids 'id_rsa'
|
||||
|
||||
#
|
||||
# utility
|
||||
#
|
||||
|
||||
# Enable spelling correction prompts.
|
||||
# See http://zsh.sourceforge.net/Doc/Release/Options.html#index-CORRECT
|
||||
#setopt CORRECT
|
||||
|
||||
# Set a custom spelling correction prompt.
|
||||
#SPROMPT='zsh: correct %F{red}%R%f to %F{green}%r%f [nyae]? '
|
||||
|
||||
#
|
||||
# zsh-autosuggestions
|
||||
#
|
||||
|
||||
# Customize the style that the suggestions are shown with.
|
||||
# See https://github.com/zsh-users/zsh-autosuggestions/blob/master/README.md#suggestion-highlight-style
|
||||
#ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE='fg=10'
|
||||
|
||||
#
|
||||
# zsh-syntax-highlighting
|
||||
#
|
||||
|
||||
# Set what highlighters will be used.
|
||||
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters.md
|
||||
ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets)
|
||||
|
||||
# Customize the main highlighter styles.
|
||||
# See https://github.com/zsh-users/zsh-syntax-highlighting/blob/master/docs/highlighters/main.md#how-to-tweak-it
|
||||
#typeset -A ZSH_HIGHLIGHT_STYLES
|
||||
#ZSH_HIGHLIGHT_STYLES[comment]='fg=10'
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
# User configuration sourced by login shells
|
||||
#
|
||||
|
||||
# Initialize zim
|
||||
# Initialize Zim
|
||||
[[ -s ${ZIM_HOME}/login_init.zsh ]] && source ${ZIM_HOME}/login_init.zsh
|
||||
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
# User configuration sourced by interactive shells
|
||||
#
|
||||
|
||||
# Define zim location
|
||||
export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
||||
# Define Zim location
|
||||
ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
||||
|
||||
# Start zim
|
||||
# Start Zim
|
||||
[[ -s ${ZIM_HOME}/init.zsh ]] && source ${ZIM_HOME}/init.zsh
|
||||
|
||||
|
|
11
tools/clean-compiled.zsh
Normal file
11
tools/clean-compiled.zsh
Normal file
|
@ -0,0 +1,11 @@
|
|||
setopt LOCAL_OPTIONS PIPE_FAIL
|
||||
local find_opt rm_opt
|
||||
if [[ ${1} != -q ]]; then
|
||||
find_opt='-print'
|
||||
rm_opt='-v'
|
||||
fi
|
||||
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -delete ${find_opt} || return 1
|
||||
command rm -f ${rm_opt} ${ZDOTDIR:-${HOME}}/.zshrc.zwc{,.old} || return 1
|
||||
if [[ ${1} != -q ]]; then
|
||||
print -P "%F{green}✓%f Done with ${0:t:r}. Run %Bzimfw compile%b to re-compile."
|
||||
fi
|
8
tools/clean-dumpfile.zsh
Normal file
8
tools/clean-dumpfile.zsh
Normal file
|
@ -0,0 +1,8 @@
|
|||
setopt LOCAL_OPTIONS PIPE_FAIL
|
||||
local zdumpfile zout zopt
|
||||
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile="${ZDOTDIR:-${HOME}}/.zcompdump"
|
||||
[[ ${1} != -q ]] && zopt='-v'
|
||||
command rm -f ${zopt} ${zdumpfile}{,.zwc{,.old}} || return 1
|
||||
if [[ ${1} != -q ]]; then
|
||||
print -P "%F{green}✓%f Done with ${0:t:r}. Restart your terminal to dump an updated configuration."
|
||||
fi
|
19
tools/clean-modules.zsh
Normal file
19
tools/clean-modules.zsh
Normal file
|
@ -0,0 +1,19 @@
|
|||
local zdir zmodule
|
||||
local -a zmodules
|
||||
local -A zoptions
|
||||
# Source .zimrc to refresh zmodules
|
||||
[[ -f ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
||||
zstyle -a ':zim' modules 'zmodules'
|
||||
for zdir in ${ZIM_HOME}/modules/*(/N); do
|
||||
zmodule=${zdir:t}
|
||||
# If zmodules does not contain the zmodule
|
||||
if (( ! ${zmodules[(I)${zmodule}]} )); then
|
||||
zstyle -a ':zim:module' ${zmodule} 'zoptions'
|
||||
[[ ${zoptions[frozen]} == yes ]] && continue
|
||||
command rm -rf ${zdir} || return 1
|
||||
[[ ${1} != -q ]] && print ${zdir}
|
||||
fi
|
||||
done
|
||||
if [[ ${1} != -q ]]; then
|
||||
print -P "%F{green}✓%f Done with ${0:t:r}."
|
||||
fi
|
3
tools/info.zsh
Normal file
3
tools/info.zsh
Normal file
|
@ -0,0 +1,3 @@
|
|||
print "Zim commit ref: $(builtin cd ${ZIM_HOME} && command git rev-parse --short HEAD)"
|
||||
print "Zsh version: ${ZSH_VERSION}"
|
||||
print "System info: $(command uname -a)"
|
18
tools/install.zsh
Normal file
18
tools/install.zsh
Normal file
|
@ -0,0 +1,18 @@
|
|||
# This runs in a new shell
|
||||
URL=${1}
|
||||
DIR=${2}
|
||||
REV=${4}
|
||||
OPT=${5}
|
||||
MODULE=${DIR:t}
|
||||
if [[ -e ${DIR} ]]; then
|
||||
# Already exists
|
||||
return 0
|
||||
fi
|
||||
if ERR=$(command git clone -b ${REV} -q --recursive ${URL} ${DIR} 2>&1); then
|
||||
if [[ ${OPT} != -q ]]; then
|
||||
print -P "%F{green}✓%f ${MODULE}: Installed"
|
||||
fi
|
||||
else
|
||||
print -P "%F{red}✗ ${MODULE}: Error%f\n${ERR}"
|
||||
return 1
|
||||
fi
|
25
tools/modules.zsh
Normal file
25
tools/modules.zsh
Normal file
|
@ -0,0 +1,25 @@
|
|||
local zmodule zurl ztype zrev
|
||||
local -a zmodules
|
||||
local -A zoptions
|
||||
zstyle -a ':zim' modules 'zmodules'
|
||||
for zmodule in ${zmodules}; do
|
||||
zstyle -a ':zim:module' ${zmodule} 'zoptions'
|
||||
[[ ${zoptions[frozen]} == yes ]] && continue
|
||||
zurl=${zoptions[url]:-${zmodule}}
|
||||
if [[ ${zurl} != /* && ${zurl} != *@*:* ]]; then
|
||||
# Count number of slashes
|
||||
case ${#zurl//[^\/]/} in
|
||||
0) zurl="https://github.com/zimfw/${zurl}.git" ;;
|
||||
1) zurl="https://github.com/${zurl}.git" ;;
|
||||
esac
|
||||
fi
|
||||
if [[ -n ${zoptions[tag]} ]]; then
|
||||
ztype=tag
|
||||
zrev=${zoptions[tag]}
|
||||
else
|
||||
ztype=branch
|
||||
zrev=${zoptions[branch]:-master}
|
||||
fi
|
||||
# Cannot have an empty space at the EOL because this is read by xargs -L1
|
||||
print "${zurl} ${ZIM_HOME}/modules/${zmodule} ${ztype} ${zrev}${1:+ ${1}}"
|
||||
done
|
58
tools/update.zsh
Normal file
58
tools/update.zsh
Normal file
|
@ -0,0 +1,58 @@
|
|||
# This runs in a new shell
|
||||
URL=${1}
|
||||
DIR=${2}
|
||||
TYPE=${3}
|
||||
REV=${4}
|
||||
OPT=${5}
|
||||
MODULE=${DIR:t}
|
||||
if ! cd ${DIR} 2>/dev/null; then
|
||||
print -P "%F{red}✗ ${MODULE}: Not installed%f"
|
||||
return 1
|
||||
fi
|
||||
if ! command git rev-parse --is-inside-work-tree &>/dev/null; then
|
||||
# Not a git repository. Will not try to update.
|
||||
return 0
|
||||
fi
|
||||
if [[ ${URL} != $(command git config --get remote.origin.url) ]]; then
|
||||
print -P "%F{red}✗ ${MODULE}: URL does not match. Expected ${URL}. Will not try to update.%f"
|
||||
return 1
|
||||
fi
|
||||
if [[ ${TYPE} == 'tag' ]]; then
|
||||
if [[ ${REV} == $(command git describe --tags --exact-match 2>/dev/null) ]]; then
|
||||
[[ ${OPT} != -q ]] && print -P "%F{green}✓%f ${MODULE}: Already up to date"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
if ! ERR=$(command git fetch -pq origin ${REV} 2>&1); then
|
||||
print -P "%F{red}✗ ${MODULE}: Error (1)%f\n${ERR}"
|
||||
return 1
|
||||
fi
|
||||
if [[ ${TYPE} == 'branch' ]]; then
|
||||
LOG_REV="${REV}@{u}"
|
||||
else
|
||||
LOG_REV=${REV}
|
||||
fi
|
||||
LOG=$(command git log --graph --color --format='%C(yellow)%h%C(reset) %s %C(cyan)(%cr)%C(reset)' ..${LOG_REV} 2>/dev/null)
|
||||
if ! ERR=$(command git checkout -q ${REV} -- 2>&1); then
|
||||
print -P "%F{red}✗ ${MODULE}: Error (2)%f\n${ERR}"
|
||||
return 1
|
||||
fi
|
||||
if [[ ${TYPE} == 'branch' ]]; then
|
||||
if ! OUT=$(command git merge --ff-only --no-progress -n 2>&1); then
|
||||
print -P "%F{red}✗ ${MODULE}: Error (3)%f\n${OUT}"
|
||||
return 1
|
||||
fi
|
||||
# keep just first line of OUT
|
||||
OUT=${OUT%%($'\n'|$'\r')*}
|
||||
else
|
||||
OUT="Updating to ${TYPE} ${REV}"
|
||||
fi
|
||||
[[ -n ${LOG} ]] && OUT="${OUT}\n${LOG}"
|
||||
if ERR=$(command git submodule update --init --recursive -q 2>&1); then
|
||||
if [[ ${OPT} != -q ]]; then
|
||||
print -P "%F{green}✓%f ${MODULE}: ${OUT}"
|
||||
fi
|
||||
else
|
||||
print -P "%F{red}✗ ${MODULE}: Error (4)%f\n${ERR}"
|
||||
return 1
|
||||
fi
|
13
tools/usage.zsh
Normal file
13
tools/usage.zsh
Normal file
|
@ -0,0 +1,13 @@
|
|||
print 'usage: zimfw <action> [-q]
|
||||
actions:
|
||||
clean Clean all (see below).
|
||||
clean-modules Clean unused modules.
|
||||
clean-compiled Clean Zsh compiled files.
|
||||
clean-dumpfile Clean completion dump file.
|
||||
compile Compile Zsh files.
|
||||
info Print Zim and system info.
|
||||
install Install new modules.
|
||||
update Update current modules.
|
||||
upgrade Upgrade Zim.
|
||||
options:
|
||||
-q Quiet, only outputs errors.'
|
|
@ -1,7 +0,0 @@
|
|||
#
|
||||
# zim_build_cache - rebuilds the zim cache
|
||||
#
|
||||
|
||||
source ${ZIM_HOME}/login_init.zsh
|
||||
|
||||
print 'To rebuild the completion cache, please restart your terminal'
|
|
@ -1,7 +0,0 @@
|
|||
#
|
||||
# zim_clean_cache - removes all zcompiled files
|
||||
#
|
||||
|
||||
find ${ZIM_HOME} \( -name '*.zwc' -or -name '*.zwc.old' \) -delete
|
||||
rm -f ${ZDOTDIR:-${HOME}}/.zshrc.zwc{,.old}
|
||||
rm -f ${ZDOTDIR:-${HOME}}/${zcompdump_file:-.zcompdump}{,.zwc{,.old}}
|
|
@ -1,9 +0,0 @@
|
|||
#
|
||||
# zim_info - prints zim and system info
|
||||
#
|
||||
|
||||
cd ${ZIM_HOME}
|
||||
|
||||
print "Zim commit ref: $(command git rev-parse --short HEAD)"
|
||||
print "Zsh version: $(command zsh --version)"
|
||||
print "System info: $(command uname -a)"
|
|
@ -1,65 +0,0 @@
|
|||
#
|
||||
# zim_info - easily create an issue template
|
||||
#
|
||||
|
||||
# create our 'pause' function
|
||||
waiter_func() {
|
||||
local input_key
|
||||
read -sk \?"Press [Enter] to continue; anything else to quit." input_key
|
||||
if [[ ${input_key} == $'\n' ]]; then
|
||||
print "\r "
|
||||
return 0
|
||||
else
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
# print init dialog
|
||||
print "Please check the existing issues to make sure you\'re not duplicating a report"
|
||||
print "https://github.com/zimfw/zimfw/issues"
|
||||
|
||||
# if they don't accept, bail
|
||||
if ! waiter_func; then
|
||||
return 1
|
||||
fi
|
||||
|
||||
# for convenience, this is our new home
|
||||
cd ${ZIM_HOME}
|
||||
|
||||
# collect sys info
|
||||
local git_dirty=$(command git status --porcelain 2>/dev/null | tail -n1)
|
||||
local zim_info=$(zsh tools/zim_info)
|
||||
|
||||
print "Environment Info
|
||||
----------------
|
||||
${zim_info}
|
||||
|
||||
Description
|
||||
-----------
|
||||
${user_desc}
|
||||
|
||||
Steps to Reproduce
|
||||
------------------
|
||||
${user_reproduce}
|
||||
|
||||
Images or other Information
|
||||
---------------------------
|
||||
"
|
||||
|
||||
|
||||
# if we have a dirty git, report it
|
||||
if [[ -n ${git_dirty} ]]; then
|
||||
print "${ZIM_HOME} has a dirty git working tree."
|
||||
print "here is the diff:"
|
||||
print '```'
|
||||
print $(command git diff)
|
||||
print '```'
|
||||
fi
|
||||
|
||||
|
||||
print '\n\n'
|
||||
print 'Please copy the above and use this when reporting the issue\n'
|
||||
|
||||
# optionally, now we can produce debug info
|
||||
print 'If you would like to produce some helpful logs about your environment, run:'
|
||||
print '$ zmanage debug'
|
|
@ -1,13 +0,0 @@
|
|||
#
|
||||
# zim_remove - removes zim from the system
|
||||
#
|
||||
# Note: this doesn't remove _everything_. It removes as much as
|
||||
# possible while maintaining safety (don't delete custom user content).
|
||||
#
|
||||
|
||||
sed '/# Source zim/,/fi/d' ${ZDOTDIR:-${HOME}}/.zshrc
|
||||
sed '/# The following code helps/,/) &!/d' ${ZDOTDIR:-${HOME}}/.zlogin
|
||||
rm -f ${ZDOTDIR:-${HOME}}/.zimrc
|
||||
|
||||
# not forcing this one, as it is recursive. It's possible something went wrong.
|
||||
rm -r ${ZIM_HOME}
|
|
@ -1,6 +0,0 @@
|
|||
#
|
||||
# zim_reset - resets the zim repository to latest commit
|
||||
#
|
||||
|
||||
cd ${ZIM_HOME}
|
||||
git reset --hard
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue