Merge branch 'develop'
This commit is contained in:
commit
edee218bb6
116 changed files with 1032 additions and 3667 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,4 +1,9 @@
|
||||||
*.swp
|
*.swp
|
||||||
*.zwc
|
*.zwc
|
||||||
*.zwc.old
|
*.zwc.old
|
||||||
custom/
|
/modules/
|
||||||
|
/init.zsh
|
||||||
|
/init.zsh.old
|
||||||
|
/login_init.zsh
|
||||||
|
/login_init.zsh.old
|
||||||
|
/zimfw.zsh.old
|
||||||
|
|
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
|
|
22
LICENSE
Normal file
22
LICENSE
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2015-2016 Matt Hamilton and contributors
|
||||||
|
Copyright (c) 2016-2019 Eric Nielsen, Matt Hamilton and contributors
|
||||||
|
|
||||||
|
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.
|
26
LICENSE.md
26
LICENSE.md
|
@ -1,26 +0,0 @@
|
||||||
MIT License
|
|
||||||
===========
|
|
||||||
|
|
||||||
Copyright (c) 2015-2016 Matt Hamilton and contributors
|
|
||||||
Copyright (c) 2016-2019 Eric Nielsen, Matt Hamilton and contributors
|
|
||||||
|
|
||||||
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.
|
|
4
Makefile
Normal file
4
Makefile
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
srcfiles := src/zimfw.zsh.erb $(wildcard src/*/*.erb)
|
||||||
|
|
||||||
|
zimfw.zsh: $(srcfiles)
|
||||||
|
erb $< >| $@
|
140
README.md
140
README.md
|
@ -3,96 +3,142 @@ Zsh IMproved FrameWork
|
||||||
|
|
||||||
<div align="center">
|
<div align="center">
|
||||||
<a href="https://github.com/zimfw/zimfw">
|
<a href="https://github.com/zimfw/zimfw">
|
||||||
<img width=650px src="https://zimfw-static.s3.wasabisys.com/zimfw_banner.png">
|
<img width=650px src="https://zimfw.github.io/images/zim_banner.png">
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
What is Zim?
|
What is Zim?
|
||||||
------------
|
------------
|
||||||
Zim is a Zsh configuration framework with [blazing speed][speed] and modular extensions.
|
Zim is a Zsh configuration framework with [blazing speed] and modular extensions.
|
||||||
|
|
||||||
Zim is very easy to customize, and comes with a rich set of modules and features without compromising on speed or functionality!
|
Zim is very easy to customize, and comes with a rich set of modules and features without compromising on speed or functionality!
|
||||||
|
|
||||||
What does Zim offer?
|
What does Zim offer?
|
||||||
-----------------
|
-----------------
|
||||||
If you're here, it means you want to see the cool shit Zim can do. Check out the [available modules][modules]!
|
If you're here, it means you want to see the cool shit Zim can do. Check out the [available modules]!
|
||||||
|
|
||||||
Below is a brief showcase of Zim's features.
|
Below is a brief showcase of Zim's features.
|
||||||
|
|
||||||
### Speed
|
### Speed
|
||||||
For a speed comparison between Zim and other frameworks, see [this wiki entry][speed].
|
For a speed comparison between Zim and other frameworks, see [this wiki entry][blazing speed].
|
||||||
|
|
||||||
### Themes
|
### Themes
|
||||||
|
|
||||||
To preview some of the available themes, check the [themes wiki page][themes].
|
To preview some of the available themes, check the [themes wiki page].
|
||||||
|
|
||||||
### Fish-shell history navigation
|
### Fish-shell history navigation
|
||||||
![history-substring-search][fish_shell]
|
![history-substring-search]
|
||||||
|
|
||||||
### Syntax highlighting
|
### Syntax highlighting
|
||||||
![syntax-highlighting][syntax_highlighting]
|
![syntax-highlighting]
|
||||||
|
|
||||||
### And much more!
|
### And much more!
|
||||||
Zim has many modules! Enable as many or as few as you'd like.
|
Zim has many modules! Enable as many or as few as you'd like.
|
||||||
|
|
||||||
Installation
|
Installation
|
||||||
------------
|
------------
|
||||||
Installing Zim is easy. If you have a different shell framework installed (like oh-my-zsh or prezto),
|
Installing Zim is easy:
|
||||||
*uninstall those first to prevent conflicts*. It can be installed manually by following the instructions below:
|
|
||||||
|
|
||||||
1. Start a Zsh shell:
|
* With curl:
|
||||||
|
|
||||||
|
curl -fsSL https://raw.githubusercontent.com/zimfw/install/develop/install.zsh | zsh
|
||||||
|
|
||||||
|
* With wget:
|
||||||
|
|
||||||
|
wget -nv -O - https://raw.githubusercontent.com/zimfw/install/develop/install.zsh | zsh
|
||||||
|
|
||||||
|
Open a new terminal and you're done! Enjoy your Zsh IMproved! Take some time to
|
||||||
|
read about the [available modules] and tweak your `.zshrc` file.
|
||||||
|
|
||||||
|
If you have a different shell framework installed (like oh-my-zsh or prezto),
|
||||||
|
*uninstall those first to prevent conflicts*.
|
||||||
|
|
||||||
|
### Manual installation
|
||||||
|
|
||||||
|
1. Start a Zsh shell
|
||||||
|
|
||||||
zsh
|
zsh
|
||||||
|
|
||||||
2. Clone the repository:
|
2. Set Zsh as the default shell:
|
||||||
|
|
||||||
git clone --recursive https://github.com/zimfw/zimfw.git ${ZDOTDIR:-${HOME}}/.zim
|
|
||||||
|
|
||||||
3. Paste this into your terminal to prepend the initialization templates to your configs:
|
|
||||||
|
|
||||||
for template_file in ${ZDOTDIR:-${HOME}}/.zim/templates/*; do
|
|
||||||
user_file="${ZDOTDIR:-${HOME}}/.${template_file:t}"
|
|
||||||
cat ${template_file} ${user_file}(.N) > ${user_file}.tmp && mv ${user_file}{.tmp,}
|
|
||||||
done
|
|
||||||
|
|
||||||
4. Set Zsh as the default shell:
|
|
||||||
|
|
||||||
chsh -s =zsh
|
chsh -s =zsh
|
||||||
|
|
||||||
5. Open a new terminal and finish optimization (this is only needed once, hereafter it will happen upon desktop/tty login):
|
3. Copy https://raw.githubusercontent.com/zimfw/zimfw/develop/zimfw.zsh to
|
||||||
|
`~/.zim/zimfw.zsh`.
|
||||||
|
|
||||||
source ${ZDOTDIR:-${HOME}}/.zlogin
|
4. Add the lines in the following templates to the respective dot files:
|
||||||
|
* [~/.zshenv](https://github.com/zimfw/install/blob/develop/src/templates/zshenv)
|
||||||
|
* [~/.zshrc](https://github.com/zimfw/install/blob/develop/src/templates/zshrc)
|
||||||
|
* [~/.zlogin](https://github.com/zimfw/install/blob/develop/src/templates/zlogin)
|
||||||
|
* [~/.zimrc](https://github.com/zimfw/install/blob/develop/src/templates/zimrc)
|
||||||
|
|
||||||
6. You're done! Enjoy your Zsh IMproved! Take some time to read about the [available modules][modules] and tweak your `.zshrc` file.
|
5. Install the modules defined in `~/.zimrc` and build the initialization scripts:
|
||||||
|
|
||||||
Updating
|
source ~/.zim/zimfw.zsh install
|
||||||
--------
|
|
||||||
|
|
||||||
To update Zim, run:
|
Usage
|
||||||
|
-----
|
||||||
|
|
||||||
zmanage update
|
### zmodule
|
||||||
|
|
||||||
For more information about the `zmanage` tool, run `zmanage help`.
|
Add `zmodule` calls to your `~/.zimrc` file to define the modules to be initialized.
|
||||||
|
The modules are initialized in the same order they are defined. Add:
|
||||||
|
|
||||||
|
zmodule <url> [-n|--name <module_name>] [options]
|
||||||
|
|
||||||
|
where `<url>` is the required repository URL or path. The following formats
|
||||||
|
are equivalent: `name`, `zimfw/name`, `https://github.com/zimfw/name.git`.
|
||||||
|
|
||||||
|
By default, the module name is the last component in the `<url>`. Use the
|
||||||
|
`-n|--name <module_name>` option to set a custom module name.
|
||||||
|
|
||||||
|
#### Repository options
|
||||||
|
|
||||||
|
* `-b|--branch <branch_name>`: Use specified branch when installing and
|
||||||
|
updating the module. Overrides the tag option. Default: `master`.
|
||||||
|
* `-t|--tag <tag_name>`: Use specified tag when installing and updating the
|
||||||
|
module. Overrides the branch option.
|
||||||
|
* `-z|--frozen`: Don't install or update the module.
|
||||||
|
|
||||||
|
#### Initialization options
|
||||||
|
|
||||||
|
* `-f|--fpath <path>`: Add specified path to `fpath`. The path is relative to
|
||||||
|
the module root directory. Default: `functions`, if the subdirectory exists.
|
||||||
|
* `-a|--autoload <function_name>`: Autoload specified function. Default: all
|
||||||
|
valid names inside the module's specified `fpath` paths.
|
||||||
|
* `-s|--source <file_path>`: Source specified file. The file path is relative
|
||||||
|
to the module root directory. Default: the file with largest size matching
|
||||||
|
`{init.zsh|module_name.{zsh|plugin.zsh|zsh-theme|sh}}`, if any exists.
|
||||||
|
* `-d|--disabled`: Don't use or uninstall the module.
|
||||||
|
|
||||||
|
### zimfw
|
||||||
|
|
||||||
|
Added new modules to `~/.zimrc`? Run:
|
||||||
|
|
||||||
|
zimfw install
|
||||||
|
|
||||||
|
Removed modules from `~/.zimrc`? Run:
|
||||||
|
|
||||||
|
zimfw uninstall
|
||||||
|
|
||||||
|
Want to update your modules to their latest revisions? Run:
|
||||||
|
|
||||||
|
zimfw update
|
||||||
|
|
||||||
|
Want to upgrade `~/.zim/zimfw.zsh` to the latest version? Run:
|
||||||
|
|
||||||
|
zimfw upgrade
|
||||||
|
|
||||||
|
For more information about the `zimfw` tool, run `zimfw` with no parameters.
|
||||||
|
|
||||||
Uninstalling
|
Uninstalling
|
||||||
------------
|
------------
|
||||||
|
|
||||||
The best way to remove Zim is to manually delete `~/.zim`, `~/.zimrc`, and
|
The best way to remove Zim is to manually delete `~/.zim`, `~/.zimrc`, and
|
||||||
remove the initialization lines from your `~/.zshrc` and `~/.zlogin`.
|
remove the initialization lines from your `~/.zshenv`, `~/.zshrc` and `~/.zlogin`.
|
||||||
|
|
||||||
However, there are some **experimental** convenience functions to remove Zim:
|
[history-substring-search]: https://zimfw.github.io/images/zim_history-substring-search.gif
|
||||||
|
[syntax-highlighting]: https://zimfw.github.io/images/zim_syntax-highlighting.gif
|
||||||
**NOTE: This functionality is experimental!**
|
[blazing speed]: https://github.com/zimfw/zimfw/wiki/Speed
|
||||||
|
[available modules]: https://github.com/zimfw/zimfw/wiki/Modules
|
||||||
To remove Zim, run:
|
[themes wiki page]: https://github.com/zimfw/zimfw/wiki/Themes
|
||||||
|
|
||||||
zmanage remove
|
|
||||||
|
|
||||||
**NOTE: This functionality is experimental!**
|
|
||||||
|
|
||||||
|
|
||||||
[fish_shell]: https://zimfw-static.s3.wasabisys.com/zimfw_history-substring-search.gif
|
|
||||||
[syntax_highlighting]: https://zimfw-static.s3.wasabisys.com/zimfw_syntax-highlighting.gif
|
|
||||||
[speed]: https://github.com/zimfw/zimfw/wiki/Speed
|
|
||||||
[modules]: https://github.com/zimfw/zimfw/wiki/Modules
|
|
||||||
[themes]: https://github.com/zimfw/zimfw/wiki/Themes
|
|
||||||
|
|
94
init.zsh
94
init.zsh
|
@ -1,94 +0,0 @@
|
||||||
#
|
|
||||||
# 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
|
|
||||||
return 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Define zim location
|
|
||||||
(( ! ${+ZIM_HOME} )) && export ZIM_HOME=${ZDOTDIR:-${HOME}}/.zim
|
|
||||||
|
|
||||||
# Source user configuration
|
|
||||||
[[ -s ${ZDOTDIR:-${HOME}}/.zimrc ]] && source ${ZDOTDIR:-${HOME}}/.zimrc
|
|
||||||
|
|
||||||
# Set input mode before loading modules
|
|
||||||
if [[ ${zinput_mode} == 'vi' ]]; then
|
|
||||||
bindkey -v
|
|
||||||
else
|
|
||||||
bindkey -e
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Autoload module functions
|
|
||||||
() {
|
|
||||||
local mod_function
|
|
||||||
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}
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
# Initialize modules
|
|
||||||
() {
|
|
||||||
local zmodule zmodule_dir zmodule_file
|
|
||||||
|
|
||||||
for zmodule in ${zmodules}; do
|
|
||||||
zmodule_dir=${ZIM_HOME}/modules/${zmodule}
|
|
||||||
if [[ ! -d ${zmodule_dir} ]]; then
|
|
||||||
print "No such module \"${zmodule}\"." >&2
|
|
||||||
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}
|
|
||||||
break
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
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"
|
|
||||||
|
|
||||||
if (( ${#} != 1 )); then
|
|
||||||
print ${usage}
|
|
||||||
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
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
}
|
|
|
@ -1,33 +0,0 @@
|
||||||
#
|
|
||||||
# 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
|
|
||||||
) &!
|
|
|
@ -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 146020d9b28c70a5edd93d19bbef9c5cb05d4b62
|
|
|
@ -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 cf565254e26bb7ce03f51889e9a29953b955b1fb
|
|
|
@ -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,238 +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.
|
|
||||||
* `glr` manages reflog information.
|
|
||||||
|
|
||||||
### Merge
|
|
||||||
|
|
||||||
* `gm` joins two or more development histories together.
|
|
||||||
* `gma` aborts the conflict resolution, and reconstructs the pre-merge state.
|
|
||||||
* `gmC` performs the merge but does not commit.
|
|
||||||
* `gmF` performs the merge generating a commit even if the merge resolved as a
|
|
||||||
fast-forward.
|
|
||||||
* `gmS` commits with GPG signature.
|
|
||||||
* `gmv` verifies the GPG signature of the tip commit of the side branch being
|
|
||||||
merged.
|
|
||||||
* `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.
|
|
||||||
|
|
||||||
Settings
|
|
||||||
--------
|
|
||||||
|
|
||||||
By default, all aliases are defined with a `g` prefix, as you can see above. But
|
|
||||||
some of the default aliases may shadow system commands, like `gpt` for the GUID
|
|
||||||
partition table maintenance utility.
|
|
||||||
|
|
||||||
You can temporarily bypass an alias by prefixing it with a backward slash:
|
|
||||||
`\gpt`.
|
|
||||||
|
|
||||||
Or you can use the following zstyle if you wish to customize the prefix used to
|
|
||||||
define all aliases:
|
|
||||||
|
|
||||||
zstyle ':zim:git' aliases-prefix 'G'
|
|
||||||
|
|
||||||
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,192 +0,0 @@
|
||||||
#
|
|
||||||
# Git aliases.
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# Settings
|
|
||||||
#
|
|
||||||
|
|
||||||
# Log colour scheme has bold yellow commit hash, bold blue author, cyan date, auto ref names
|
|
||||||
# See https://git-scm.com/docs/pretty-formats
|
|
||||||
_git_log_fuller_format='%C(bold yellow)commit %H%C(auto)%d%n%C(bold)Author: %C(blue)%an <%ae> %C(no-bold cyan)%ai (%ar)%n%C(bold)Commit: %C(blue)%cn <%ce> %C(no-bold cyan)%ci (%cr)%C(reset)%n%+B'
|
|
||||||
_git_log_oneline_format='%C(bold yellow)%h%C(reset) %s%C(auto)%d%C(reset)'
|
|
||||||
_git_log_oneline_medium_format='%C(bold yellow)%h%C(reset) %<(50,trunc)%s %C(bold blue)<%an> %C(no-bold cyan)(%ar)%C(auto)%d%C(reset)'
|
|
||||||
|
|
||||||
#
|
|
||||||
# Aliases
|
|
||||||
#
|
|
||||||
|
|
||||||
() {
|
|
||||||
local gprefix
|
|
||||||
zstyle -s ':zim:git' aliases-prefix 'gprefix' || gprefix=g
|
|
||||||
|
|
||||||
# Git
|
|
||||||
alias ${gprefix}='git'
|
|
||||||
|
|
||||||
# Branch (b)
|
|
||||||
alias ${gprefix}b='git branch'
|
|
||||||
alias ${gprefix}bc='git checkout -b'
|
|
||||||
alias ${gprefix}bl='git branch -vv'
|
|
||||||
alias ${gprefix}bL='git branch --all -vv'
|
|
||||||
alias ${gprefix}bm='git branch --move'
|
|
||||||
alias ${gprefix}bM='git branch --move --force'
|
|
||||||
alias ${gprefix}bs='git show-branch'
|
|
||||||
alias ${gprefix}bS='git show-branch --all'
|
|
||||||
alias ${gprefix}bx='git-branch-delete-interactive'
|
|
||||||
alias ${gprefix}bX='git-branch-delete-interactive --force'
|
|
||||||
|
|
||||||
# Commit (c)
|
|
||||||
alias ${gprefix}c='git commit --verbose'
|
|
||||||
alias ${gprefix}ca='git commit --verbose --all'
|
|
||||||
alias ${gprefix}cm='git commit --message'
|
|
||||||
alias ${gprefix}co='git checkout'
|
|
||||||
alias ${gprefix}cO='git checkout --patch'
|
|
||||||
alias ${gprefix}cf='git commit --amend --reuse-message HEAD'
|
|
||||||
alias ${gprefix}cF='git commit --verbose --amend'
|
|
||||||
alias ${gprefix}cp='git cherry-pick --ff'
|
|
||||||
alias ${gprefix}cP='git cherry-pick --no-commit'
|
|
||||||
alias ${gprefix}cr='git revert'
|
|
||||||
alias ${gprefix}cR='git reset "HEAD^"'
|
|
||||||
alias ${gprefix}cs='git show --pretty=format:"${_git_log_fuller_format}"'
|
|
||||||
alias ${gprefix}cS='git commit -S'
|
|
||||||
alias ${gprefix}cv='git verify-commit'
|
|
||||||
|
|
||||||
# Conflict (C)
|
|
||||||
alias ${gprefix}Cl='git --no-pager diff --diff-filter=U --name-only'
|
|
||||||
alias ${gprefix}Ca='git add $(gCl)'
|
|
||||||
alias ${gprefix}Ce='git mergetool $(gCl)'
|
|
||||||
alias ${gprefix}Co='git checkout --ours --'
|
|
||||||
alias ${gprefix}CO='gCo $(gCl)'
|
|
||||||
alias ${gprefix}Ct='git checkout --theirs --'
|
|
||||||
alias ${gprefix}CT='gCt $(gCl)'
|
|
||||||
|
|
||||||
# Data (d)
|
|
||||||
alias ${gprefix}d='git ls-files'
|
|
||||||
alias ${gprefix}dc='git ls-files --cached'
|
|
||||||
alias ${gprefix}dx='git ls-files --deleted'
|
|
||||||
alias ${gprefix}dm='git ls-files --modified'
|
|
||||||
alias ${gprefix}du='git ls-files --other --exclude-standard'
|
|
||||||
alias ${gprefix}dk='git ls-files --killed'
|
|
||||||
alias ${gprefix}di='git status --porcelain --short --ignored | sed -n "s/^!! //p"'
|
|
||||||
|
|
||||||
# Fetch (f)
|
|
||||||
alias ${gprefix}f='git fetch'
|
|
||||||
alias ${gprefix}fc='git clone'
|
|
||||||
alias ${gprefix}fm='git pull'
|
|
||||||
alias ${gprefix}fr='git pull --rebase'
|
|
||||||
alias ${gprefix}fu='git fetch --all --prune && git merge --ff-only @\{u\}'
|
|
||||||
|
|
||||||
# Grep (g)
|
|
||||||
alias ${gprefix}g='git grep'
|
|
||||||
alias ${gprefix}gi='git grep --ignore-case'
|
|
||||||
alias ${gprefix}gl='git grep --files-with-matches'
|
|
||||||
alias ${gprefix}gL='git grep --files-without-match'
|
|
||||||
alias ${gprefix}gv='git grep --invert-match'
|
|
||||||
alias ${gprefix}gw='git grep --word-regexp'
|
|
||||||
|
|
||||||
# Index (i)
|
|
||||||
alias ${gprefix}ia='git add'
|
|
||||||
alias ${gprefix}iA='git add --patch'
|
|
||||||
alias ${gprefix}iu='git add --update'
|
|
||||||
alias ${gprefix}id='git diff --no-ext-diff --cached'
|
|
||||||
alias ${gprefix}iD='git diff --no-ext-diff --cached --word-diff'
|
|
||||||
alias ${gprefix}ir='git reset'
|
|
||||||
alias ${gprefix}iR='git reset --patch'
|
|
||||||
alias ${gprefix}ix='git rm --cached -r'
|
|
||||||
alias ${gprefix}iX='git rm --cached -rf'
|
|
||||||
|
|
||||||
# Log (l)
|
|
||||||
alias ${gprefix}l='git log --topo-order --pretty=format:"${_git_log_fuller_format}"'
|
|
||||||
alias ${gprefix}ls='git log --topo-order --stat --pretty=format:"${_git_log_fuller_format}"'
|
|
||||||
alias ${gprefix}ld='git log --topo-order --stat --patch --full-diff --pretty=format:"${_git_log_fuller_format}"'
|
|
||||||
alias ${gprefix}lo='git log --topo-order --pretty=format:"${_git_log_oneline_format}"'
|
|
||||||
alias ${gprefix}lO='git log --topo-order --pretty=format:"${_git_log_oneline_medium_format}"'
|
|
||||||
alias ${gprefix}lg='git log --graph --pretty=format:"${_git_log_oneline_format}"'
|
|
||||||
alias ${gprefix}lG='git log --graph --pretty=format:"${_git_log_oneline_medium_format}"'
|
|
||||||
alias ${gprefix}lv='git log --topo-order --show-signature --pretty=format:"${_git_log_fuller_format}"'
|
|
||||||
alias ${gprefix}lc='git shortlog --summary --numbered'
|
|
||||||
alias ${gprefix}lr='git reflog'
|
|
||||||
|
|
||||||
# Merge (m)
|
|
||||||
alias ${gprefix}m='git merge'
|
|
||||||
alias ${gprefix}ma='git merge --abort'
|
|
||||||
alias ${gprefix}mC='git merge --no-commit'
|
|
||||||
alias ${gprefix}mF='git merge --no-ff'
|
|
||||||
alias ${gprefix}mS='git merge -S'
|
|
||||||
alias ${gprefix}mv='git merge --verify-signatures'
|
|
||||||
alias ${gprefix}mt='git mergetool'
|
|
||||||
|
|
||||||
# Push (p)
|
|
||||||
alias ${gprefix}p='git push'
|
|
||||||
alias ${gprefix}pf='git push --force-with-lease'
|
|
||||||
alias ${gprefix}pF='git push --force'
|
|
||||||
alias ${gprefix}pa='git push --all'
|
|
||||||
alias ${gprefix}pA='git push --all && git push --tags'
|
|
||||||
alias ${gprefix}pt='git push --tags'
|
|
||||||
alias ${gprefix}pc='git push --set-upstream origin "$(git-branch-current 2> /dev/null)"'
|
|
||||||
alias ${gprefix}pp='git pull origin "$(git-branch-current 2> /dev/null)" && git push origin "$(git-branch-current 2> /dev/null)"'
|
|
||||||
|
|
||||||
# Rebase (r)
|
|
||||||
alias ${gprefix}r='git rebase'
|
|
||||||
alias ${gprefix}ra='git rebase --abort'
|
|
||||||
alias ${gprefix}rc='git rebase --continue'
|
|
||||||
alias ${gprefix}ri='git rebase --interactive'
|
|
||||||
alias ${gprefix}rs='git rebase --skip'
|
|
||||||
|
|
||||||
# Remote (R)
|
|
||||||
alias ${gprefix}R='git remote'
|
|
||||||
alias ${gprefix}Rl='git remote --verbose'
|
|
||||||
alias ${gprefix}Ra='git remote add'
|
|
||||||
alias ${gprefix}Rx='git remote rm'
|
|
||||||
alias ${gprefix}Rm='git remote rename'
|
|
||||||
alias ${gprefix}Ru='git remote update'
|
|
||||||
alias ${gprefix}Rp='git remote prune'
|
|
||||||
alias ${gprefix}Rs='git remote show'
|
|
||||||
|
|
||||||
# Stash (s)
|
|
||||||
alias ${gprefix}s='git stash'
|
|
||||||
alias ${gprefix}sa='git stash apply'
|
|
||||||
alias ${gprefix}sx='git stash drop'
|
|
||||||
alias ${gprefix}sX='git-stash-clear-interactive'
|
|
||||||
alias ${gprefix}sl='git stash list'
|
|
||||||
alias ${gprefix}sd='git stash show --patch --stat'
|
|
||||||
alias ${gprefix}sp='git stash pop'
|
|
||||||
alias ${gprefix}sr='git-stash-recover'
|
|
||||||
alias ${gprefix}ss='git stash save --include-untracked'
|
|
||||||
alias ${gprefix}sS='git stash save --patch --no-keep-index'
|
|
||||||
alias ${gprefix}sw='git stash save --include-untracked --keep-index'
|
|
||||||
alias ${gprefix}su='git stash show --patch | git apply --reverse'
|
|
||||||
|
|
||||||
# Submodule (S)
|
|
||||||
alias ${gprefix}S='git submodule'
|
|
||||||
alias ${gprefix}Sa='git submodule add'
|
|
||||||
alias ${gprefix}Sf='git submodule foreach'
|
|
||||||
alias ${gprefix}Si='git submodule init'
|
|
||||||
alias ${gprefix}SI='git submodule update --init --recursive'
|
|
||||||
alias ${gprefix}Sl='git submodule status'
|
|
||||||
alias ${gprefix}Sm='git-submodule-move'
|
|
||||||
alias ${gprefix}Ss='git submodule sync'
|
|
||||||
alias ${gprefix}Su='git submodule foreach git pull origin master'
|
|
||||||
alias ${gprefix}Sx='git-submodule-remove'
|
|
||||||
|
|
||||||
# Tag (t)
|
|
||||||
alias ${gprefix}t='git tag'
|
|
||||||
alias ${gprefix}ts='git tag --sign'
|
|
||||||
alias ${gprefix}tv='git verify-tag'
|
|
||||||
alias ${gprefix}tx='git tag --delete'
|
|
||||||
|
|
||||||
# Working tree (w)
|
|
||||||
alias ${gprefix}ws='git status --short'
|
|
||||||
alias ${gprefix}wS='git status'
|
|
||||||
alias ${gprefix}wd='git diff --no-ext-diff'
|
|
||||||
alias ${gprefix}wD='git diff --no-ext-diff --word-diff'
|
|
||||||
alias ${gprefix}wr='git reset --soft'
|
|
||||||
alias ${gprefix}wR='git reset --hard'
|
|
||||||
alias ${gprefix}wc='git clean --dry-run'
|
|
||||||
alias ${gprefix}wC='git clean -d --force'
|
|
||||||
alias ${gprefix}wx='git rm -r'
|
|
||||||
alias ${gprefix}wX='git rm -rf'
|
|
||||||
|
|
||||||
# Misc
|
|
||||||
alias ${gprefix}..='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://zimfw-static.s3.wasabisys.com/zimfw_history-substring-search.gif
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 0f80b8eb3368b46e5e573c1d91ae69eb095db3fb
|
|
|
@ -1,17 +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
|
|
||||||
if [[ -n ${terminfo[kcuu1]} && -n ${terminfo[kcud1]} ]]; then
|
|
||||||
bindkey ${terminfo[kcuu1]} history-substring-search-up
|
|
||||||
bindkey ${terminfo[kcud1]} history-substring-search-down
|
|
||||||
fi
|
|
|
@ -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 1217934fcb2e575b87d94701fc21378ff41df1be
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 5f4aeece8d6cf98138e729f7833e11e985ca44d3
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit 2e354b80deae105ea246699c49e65dcd4fe8b759
|
|
|
@ -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://zimfw-static.s3.wasabisys.com/zimfw_syntax-highlighting.gif
|
|
|
@ -1 +0,0 @@
|
||||||
Subproject commit e7d3fbc50b0209cb9f9b0812fd40298be03c7808
|
|
|
@ -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
|
|
7
src/stage2/20_guard.zsh.erb
Normal file
7
src/stage2/20_guard.zsh.erb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
autoload -Uz is-at-least && if ! is-at-least <%= min_zsh_version %>; then
|
||||||
|
print -u2 -R "${0}: Error starting Zim. You're using Zsh version ${ZSH_VERSION} and versions < <%= min_zsh_version %> are not supported. Update your Zsh."
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Define Zim location
|
||||||
|
: ${ZIM_HOME=${0:A:h}}
|
15
src/stage2/28_zimfw_mv.zsh.erb
Normal file
15
src/stage2/28_zimfw_mv.zsh.erb
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
_zimfw_mv() {
|
||||||
|
if command cmp -s ${2} ${1}; then
|
||||||
|
if (( ! _zquiet )); then
|
||||||
|
print -PR "<%= okay %>%B${2}:%b Already up to date"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if [[ -e ${2} ]]; then
|
||||||
|
command mv -f ${2}{,.old} || return 1
|
||||||
|
fi
|
||||||
|
command mv -f ${1} ${2} && \
|
||||||
|
if (( ! _zquiet )); then
|
||||||
|
print -PR "<%= okay %>%B${2}:%b Updated. Restart your terminal for changes to take effect."
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
13
src/stage2/29_zimfw_build_init.zsh.erb
Normal file
13
src/stage2/29_zimfw_build_init.zsh.erb
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
_zimfw_build_init() {
|
||||||
|
local -r ztarget=${ZIM_HOME}/init.zsh
|
||||||
|
# Force update of init.zsh if it's older than .zimrc
|
||||||
|
if [[ ${ztarget} -ot <%= home %>/.zimrc ]]; then
|
||||||
|
command mv -f ${ztarget}{,.old} || return 1
|
||||||
|
fi
|
||||||
|
_zimfw_mv =(
|
||||||
|
print -R "zimfw() { source ${ZIM_HOME}/<%= script_filename %> \"\${@}\" }"
|
||||||
|
(( ${#_zfpaths} )) && print -R 'fpath=('${_zfpaths:P}' ${fpath})'
|
||||||
|
(( ${#_zfunctions} )) && print -R 'autoload -Uz '${_zfunctions}
|
||||||
|
print -Rn ${(F):-source ${^_zscripts:P}}
|
||||||
|
) ${ztarget}
|
||||||
|
}
|
6
src/stage2/29_zimfw_build_login_init.zsh.erb
Normal file
6
src/stage2/29_zimfw_build_login_init.zsh.erb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
_zimfw_build_login_init() {
|
||||||
|
local -r ztarget=${ZIM_HOME}/login_init.zsh
|
||||||
|
_zimfw_mv =(
|
||||||
|
print -Rn "<%= render_escaped("src/templates/login_init.zsh.erb") %>"
|
||||||
|
) ${ztarget}
|
||||||
|
}
|
6
src/stage2/30_zimfw_build.zsh.erb
Normal file
6
src/stage2/30_zimfw_build.zsh.erb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
_zimfw_build() {
|
||||||
|
_zimfw_build_init && _zimfw_build_login_init && \
|
||||||
|
if (( ! _zquiet )); then
|
||||||
|
print -P '<%= done %>Done with build.'
|
||||||
|
fi
|
||||||
|
}
|
127
src/stage2/30_zmodule.zsh.erb
Normal file
127
src/stage2/30_zmodule.zsh.erb
Normal file
|
@ -0,0 +1,127 @@
|
||||||
|
zmodule() {
|
||||||
|
local -r zusage="
|
||||||
|
Usage: %B${0}%b <url> [%B-n%b|%B--name%b <module_name>] [options]
|
||||||
|
|
||||||
|
Repository options:
|
||||||
|
%B-b%b|%B--branch%b <branch_name> Use specified branch when installing and updating the module
|
||||||
|
%B-t%b|%B--tag%b <tag_name> Use specified tag when installing and updating the module
|
||||||
|
%B-z%b|%B--frozen%b Don't install or update the module
|
||||||
|
|
||||||
|
Startup options:
|
||||||
|
%B-f%b|%B--fpath%b <path> Add specified path to fpath
|
||||||
|
%B-a%b|%B--autoload%b <function_name> Autoload specified function
|
||||||
|
%B-s%b|%B--source%b <file_path> Source specified file
|
||||||
|
%B-d%b|%B--disabled%b Don't use or uninstall the module
|
||||||
|
"
|
||||||
|
if [[ ${${funcfiletrace[1]%:*}:t} != .zimrc ]]; then
|
||||||
|
print -u2 -PR "%F{red}${0}: Must be called from %B<%= home %>/.zimrc%b%f"$'\n'${zusage}
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
if (( ! # )); then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}: Missing zmodule url%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
setopt LOCAL_OPTIONS CASE_GLOB EXTENDED_GLOB
|
||||||
|
local zmodule=${1:t} zurl=${1}
|
||||||
|
local ztype=branch zrev=master
|
||||||
|
local -i zdisabled=0 zfrozen=0
|
||||||
|
local -a zfpaths zfunctions zscripts
|
||||||
|
local zarg
|
||||||
|
if [[ ${zurl} =~ ^[^:/]+: ]]; then
|
||||||
|
zmodule=${zmodule%.git}
|
||||||
|
elif [[ ${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
|
||||||
|
shift
|
||||||
|
if [[ ${1} == (-n|--name) ]]; then
|
||||||
|
if (( # < 2 )); then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
shift
|
||||||
|
zmodule=${1}
|
||||||
|
shift
|
||||||
|
fi
|
||||||
|
local -r zdir=${ZIM_HOME}/modules/${zmodule}
|
||||||
|
while (( # > 0 )); do
|
||||||
|
case ${1} in
|
||||||
|
-b|--branch|-t|--tag|-f|--fpath|-a|--autoload|-s|--source)
|
||||||
|
if (( # < 2 )); then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Missing argument for zmodule option ${1}%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
case ${1} in
|
||||||
|
-b|--branch)
|
||||||
|
shift
|
||||||
|
ztype=branch
|
||||||
|
zrev=${1}
|
||||||
|
;;
|
||||||
|
-t|--tag)
|
||||||
|
shift
|
||||||
|
ztype=tag
|
||||||
|
zrev=${1}
|
||||||
|
;;
|
||||||
|
-z|--frozen) zfrozen=1 ;;
|
||||||
|
-f|--fpath)
|
||||||
|
shift
|
||||||
|
zarg=${1}
|
||||||
|
[[ ${zarg} != /* ]] && zarg=${zdir}/${zarg}
|
||||||
|
zfpaths+=(${zarg})
|
||||||
|
;;
|
||||||
|
-a|--autoload)
|
||||||
|
shift
|
||||||
|
zfunctions+=(${1})
|
||||||
|
;;
|
||||||
|
-s|--source)
|
||||||
|
shift
|
||||||
|
zarg=${1}
|
||||||
|
[[ ${zarg} != /* ]] && zarg=${zdir}/${zarg}
|
||||||
|
zscripts+=(${zarg})
|
||||||
|
;;
|
||||||
|
-d|--disabled) zdisabled=1 ;;
|
||||||
|
*)
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Unknown zmodule option ${1}%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
shift
|
||||||
|
done
|
||||||
|
if (( _zprepare_xargs )); then
|
||||||
|
if (( ! zfrozen )); then
|
||||||
|
_zmodules_xargs+=${zmodule}$'\0'${zdir}$'\0'${zurl}$'\0'${ztype}$'\0'${zrev}$'\0'${_zquiet}$'\0'
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
if (( zdisabled )); then
|
||||||
|
_zdisableds+=(${zmodule})
|
||||||
|
else
|
||||||
|
if [[ ! -d ${zdir} ]]; then
|
||||||
|
print -u2 -PR "%F{red}<%= error %>${funcfiletrace[1]}:%B${zmodule}:%b Not installed%f"
|
||||||
|
_zfailed=1
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
(( ! ${#zfpaths} )) && zfpaths+=(${zdir}/functions(NF))
|
||||||
|
if (( ! ${#zfunctions} )); then
|
||||||
|
# _* functions are autoloaded by compinit
|
||||||
|
# prompt_*_setup functions are autoloaded by promptinit
|
||||||
|
zfunctions+=(${^zfpaths}/^(*~|*.zwc(|.old)|_*|prompt_*_setup)(N-.:t))
|
||||||
|
fi
|
||||||
|
if (( ! ${#zscripts} )); then
|
||||||
|
zscripts+=(${zdir}/(init.zsh|${zmodule:t}.(zsh|plugin.zsh|zsh-theme|sh))(NOL[1]))
|
||||||
|
fi
|
||||||
|
_zfpaths+=(${zfpaths})
|
||||||
|
_zfunctions+=(${zfunctions})
|
||||||
|
_zscripts+=(${zscripts})
|
||||||
|
_zmodules+=(${zmodule})
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
}
|
8
src/stage2/31_zimfw_source_zimrc.zsh.erb
Normal file
8
src/stage2/31_zimfw_source_zimrc.zsh.erb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
_zimfw_source_zimrc() {
|
||||||
|
local -ri _zprepare_xargs=${1}
|
||||||
|
local -i _zfailed=0
|
||||||
|
if ! source <%= home %>/.zimrc || (( _zfailed )); then
|
||||||
|
print -u2 -PR "%F{red}<%= failed %>Failed to source %B<%= home %>/.zimrc%b%f"
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
}
|
9
src/stage2/50_zimfw_clean_compiled.zsh.erb
Normal file
9
src/stage2/50_zimfw_clean_compiled.zsh.erb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
_zimfw_clean_compiled() {
|
||||||
|
local zopt
|
||||||
|
(( ! _zquiet )) && zopt='-v'
|
||||||
|
command find ${ZIM_HOME} \( -name '*.zwc' -o -name '*.zwc.old' \) -exec rm -f ${zopt} {} \; || return 1
|
||||||
|
command rm -f ${zopt} <%= home %>/<%= startup_files_glob %>.zwc(|.old)(N) || return 1
|
||||||
|
if (( ! _zquiet )); then
|
||||||
|
print -P '<%= done %>Done with clean-compiled. Run %Bzimfw compile%b to re-compile.'
|
||||||
|
fi
|
||||||
|
}
|
9
src/stage2/50_zimfw_clean_dumpfile.zsh.erb
Normal file
9
src/stage2/50_zimfw_clean_dumpfile.zsh.erb
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
_zimfw_clean_dumpfile() {
|
||||||
|
local zdumpfile zopt
|
||||||
|
zstyle -s ':zim:completion' dumpfile 'zdumpfile' || zdumpfile=<%= home %>/.zcompdump
|
||||||
|
(( ! _zquiet )) && zopt='-v'
|
||||||
|
command rm -f ${zopt} ${zdumpfile}(|.zwc(|.old)) || return 1
|
||||||
|
if (( ! _zquiet )); then
|
||||||
|
print -P '<%= done %>Done with clean-dumpfile. Restart your terminal to dump an updated configuration.'
|
||||||
|
fi
|
||||||
|
}
|
3
src/stage2/50_zimfw_compile.zsh.erb
Normal file
3
src/stage2/50_zimfw_compile.zsh.erb
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
_zimfw_compile() {
|
||||||
|
source ${ZIM_HOME}/login_init.zsh "${@}"
|
||||||
|
}
|
6
src/stage2/50_zimfw_info.zsh.erb
Normal file
6
src/stage2/50_zimfw_info.zsh.erb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
_zimfw_info() {
|
||||||
|
print 'Zim version: <%= version %> (previous commit is <%= `git rev-parse --short HEAD | tr -d '\r\n'` %>)'
|
||||||
|
print -R 'ZIM_HOME: '${ZIM_HOME}
|
||||||
|
print -R 'Zsh version: '${ZSH_VERSION}
|
||||||
|
print -R 'System info: '$(command uname -a)
|
||||||
|
}
|
14
src/stage2/50_zimfw_uninstall.zsh.erb
Normal file
14
src/stage2/50_zimfw_uninstall.zsh.erb
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
_zimfw_uninstall() {
|
||||||
|
local zopt zdir zmodule
|
||||||
|
(( ! _zquiet )) && zopt='-v'
|
||||||
|
for zdir in ${ZIM_HOME}/modules/*(N/); do
|
||||||
|
zmodule=${zdir:t}
|
||||||
|
# If _zmodules and _zdisableds do not contain the zmodule
|
||||||
|
if (( ! ${_zmodules[(I)${zmodule}]} && ! ${_zdisableds[(I)${zmodule}]} )); then
|
||||||
|
command rm -rf ${zopt} ${zdir} || return 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if (( ! _zquiet )); then
|
||||||
|
print -P '<%= done %>Done with uninstall.'
|
||||||
|
fi
|
||||||
|
}
|
17
src/stage2/50_zimfw_upgrade.zsh.erb
Normal file
17
src/stage2/50_zimfw_upgrade.zsh.erb
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
_zimfw_upgrade() {
|
||||||
|
local -r ztarget=${ZIM_HOME}/<%= script_filename %>
|
||||||
|
local -r zurl=https://raw.githubusercontent.com/zimfw/zimfw/develop/<%= script_filename %>
|
||||||
|
{
|
||||||
|
if (( ${+commands[wget]} )); then
|
||||||
|
command wget -nv -O ${ztarget}.new ${zurl} || return 1
|
||||||
|
else
|
||||||
|
command curl -fsSL -o ${ztarget}.new ${zurl} || return 1
|
||||||
|
fi
|
||||||
|
_zimfw_mv ${ztarget}{.new,} && \
|
||||||
|
if (( ! _zquiet )); then
|
||||||
|
print -P '<%= done %>Done with upgrade.'
|
||||||
|
fi
|
||||||
|
} always {
|
||||||
|
command rm -f ${ztarget}.new
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue