Commit Graph

626 Commits

Author SHA1 Message Date
Eric Nielsen 1980ca091d
Zim script in a single file \o/
Also moved the templates out of this repository, and into the
zimfw/install repo.

This is a second big change after introducing the plugin mechanism. This
makes installation and upgrading of Zim straightforward. Maybe the most
important aspect of having the script in a single file is not having to
manage "git repos inside git repos" (see #297), since the single file
exists by itself and is not version-controlled (with git).

I've implemented a two-stage sourcing of the file, so most of the file
is only sourced when needed (namely when calling `zimfw` with any action
other than `login-init`). The two-stage process is designed to avoid
compromising the startup speed, which is our top priority.

In an effort to help making the script maintainable, I've broken it into
small ERB templates. This also adds the ability to pre-process the Zsh
code with Ruby code. To build the script, use `make`.
2020-01-02 12:58:01 -05:00
Eric Nielsen 27508e363c
Stop supporting themes that require prompinit
Only 5% (18/342) of the themes listed under [unixorn/awesome-zsh-plugins]
are actually compatible with prompinit. Of these, [clean] also allows
being sourced directly. On the other hand, 3 others are prezto themes.

promptinit would be useful for who wants to try many themes without the
need to restart their shell session. And must be many many, so
"brute-force" starting a new shell to experiment each new theme would be
a burden! Even the cleanup feature of promptinit is still incomplete, so
you eventually get a messy prompt after trying many with it. And that's
not even a everyday use case of the average Zsh user.

So prompinit it not widely supported out there, and also not very useful
for the everyday let-me-use-my-beloved-and-carefully-customized-prompt-during-the-whole-shell-session-pleasee
scenario. It's also faster and simpler to directly just source the prompt
theme to be used, not even having to autoload promptinit and let it scan
all the others themes in fpath that won't be used.
And the Zim "philosophy" is to use fast and simple solutions.
So here we go.

Fixes #325

[unixorn/awesome-zsh-plugins]: e226f3de04/README.md (themes)
[clean]: https://github.com/BrandonRoehl/zsh-clean
2020-01-02 12:58:01 -05:00
Eric Nielsen 536d7b7890
Allow modules that are not repos
so going into their ${ZIM_HOME}/modules/foo directory would be like
still being inside the Zim repo, in ${ZIM_HOME}. Don't try to update
them in this case.

This was supposed to be working before, but my ${ZIM_HOME} was not a
repo when I was still developing this locally.
2020-01-02 12:58:00 -05:00
Eric Nielsen 2a51211ab7
Update README.md with automatic installer
Also change formatting of the settings. Using `<em></em>` to prevent
URL autolinking in some cases, and to add emphasis where `*foo*` would
be ambiguous for the Markdown format.

Copy was also slightly improved, hopefully for better clarity.
2020-01-02 12:58:00 -05:00
Eric Nielsen 8dc3e43a0d
Add a plugin mechanism \o/
This is a major change, where Zsh modules/plugins are not git submodules
in the Zim repo anymore, but customized and installed separately as
individual repositories. The discussion about this started more than 2
years ago in #88. Closes #299.

This will allow contributors' modules to live in their own repositories.
See #33, #138, #262, #281, #324.

The current code has what, up to this point, I considered to be the best
balance between simplicity, execution speed and number of files.

One measured decision was to make the initialization of modules depend
only on the `':zim' modules` style, keeping it as fast as possible.
The `':zim:module' module` style is used to install, update and clean
the modules, all operations that happen after the user got his
as-blazing-fast-possible shell prompt.

Even though I didn't care much about making install or update fast,
`xargs` has a nice feature of allowing commands to be executed in
parallel with `-P`. I took advantage of that.

I've also worked on making the `zimfw` utility give the user some nice
(while still minimalistic) output. Also I'm suggesting this as the new
name for the `zmanage` tool, since `zimfw` does not shadow the `zim`
wiki tool.
2020-01-02 12:58:00 -05:00
Eric Nielsen 5d66578c47 Update submodules
* zsh-syntax-highlighting to HEAD
* lean to HEAD
* liquidprompt to HEAD
* pure to release v1.11.0
2019-11-19 14:54:39 -05:00
Matt Hamilton 954f53d01d
update static image URL 2019-11-14 09:06:26 -05:00
Grant Guthrie d19c8dde68 [history-substring-search] Verify terminfo before bindkey
Closes #341
2019-09-28 07:57:28 -05:00
Eric Nielsen b180b40b27 Update submodules
* zsh-autosuggestions to release v0.6.3
* zsh-completions to release 0.30.0
* zsh-history-substring-search to HEAD
* zsh-syntax-highlighting to HEAD
* lean to HEAD
* liquidprompt to HEAD
* pure to release v1.10.3
2019-07-13 18:30:33 -05:00
Eric Nielsen de8027f19d Remove cursor highlighter from zimrc template
Not needed in MacOS iTerm and Terminal, (u)rxvt, termite, alacritty and
gnome-terminal.
Does it do any good in any situation?

Closes #337

The develop branch already has this out:
229cea08e5/src/templates/zimrc.zsh.erb (L83-L85)
2019-06-05 20:30:30 -05:00
Eric Nielsen accabdb18b Scope local variable in anonymous function
so it does not leek into the shell.

Copied from zimfw/git@fea95a7655
2019-06-01 00:08:28 -05:00
Eric Nielsen 507f5d58e0 Update log formats
Use fuller format with committer info instead of medium format, as that
is more complete, and info for author and committer seems to fit in one
line each.

Fix one-line medium format so it truncates the subject at 50, instead of
at the fixed column 60, as that was not good to graph logs.

Remove `--all` from graph log aliases, to increase their flexibility.
We're then able to use it just for the current or for a branch passed
as parameter (as we already could with the other log aliases).

Copied from zimfw/git@63008c817e
2019-06-01 00:07:59 -05:00
Oskar Grunning dc6ef566af [git] Add aliases for merge sign and verify
Adds the following aliases:
  - gmS: GPG-sign the resulting merge commit.
  - gmV: Verify that the tip commit of the side branch being merged is
  signed with a valid key, i.e. a key that has a valid uid: in the
  default trust model, this means the signing key has been signed by a
  trusted key. If the tip commit of the side branch is not signed with a
  valid key, the merge is aborted.

Closes #333
2019-03-22 08:35:42 -05:00
Eric Nielsen d2c1e613ae [git] Allow aliases prefix to be something else than `g`
There were a couple of reports before about aliases shadowing commands
in #59 and #139. And I was impressed to check how many actually shadow existing commands using Ubuntu's command-not-found:

    'gb'  : apt install gb
    'gc'  : apt install graphviz
    'gcp' : apt install gcp
    'gcs' : apt install opengcs
    'gcv' : apt install scotch
    'gdc' : apt install gdc
    'gfm' : apt install gfm
    'gid' : apt install id-utils
    'gld' : apt install postfix-gld
    'gm'  : apt install graphicsmagick
    'gmt' : apt install gmt
    'gp'  : apt install pari-gp
    'gpa' : apt install gpa
    'gpp' : apt install gpp
    'gpt' : apt install gpt
    'grc' : apt install grc
    'gri' : apt install gri
    'gs'  : apt install ghostscript
    'gsl' : apt install generator-scripting-language
    'gss' : apt install libgss-dev
    'gt'  : apt install genometools
    'gtv' : apt install smpeg-gtv
    'gwc' : apt install geneweb
    'gwd' : apt install geneweb

The ability to customize the prefix fixes this issue. Picking `G` for
example is a good one (Vim's Fugitive uses upper case `G` in the
beginning of is commands, to mention another place where it's used).

Closes zimfw/git#1

Copied from zimfw/git@b2a2ffbd31
2019-03-22 08:15:11 -05:00
Eric Nielsen 38b3b9517e [git] Add `glr` alias for git reflog
and change the commit format to bold yellow, since that's the default
git log format for the commit when colored.

Closes #334

Copied from zimfw/git@013c9d9bf3
2019-03-22 08:12:53 -05:00
Oskar Grunning 45927aa8a2 [prompt] lean: Update submodule
Closes #332
2019-02-22 10:50:24 -05:00
Eric Nielsen 4f6ae96b12
Update LICENSE.md
Closes #322
2019-01-15 10:42:27 -05:00
Eric Nielsen 5371975f37 Update README.md instructions
> You should never have a pipeline both reading from and writing to a file.

My bad. See https://stackoverflow.com/a/25335116/2654518

Fixes #316
2019-01-05 18:18:42 -05:00
Eric Nielsen 1ab110c264 [git-info] Add complete example to README.md
so users don't need to look at our prompts code to figure out how having
all the pieces together looks like.
2018-12-26 20:56:57 -05:00
Eric Nielsen 882408b762 [prompt] eriner: Fix ${USER} not being evaluated
I broke this on the last commit. My bad.

Fixes #318
2018-12-23 18:21:18 -05:00
Eric Nielsen 21696a4f70 [git-info] Document that flag (e) is needed
so proper expansion of ref names occurs, due to changes done in 53a3cd7.
2018-12-21 22:48:54 -05:00
Eric Nielsen 5b90c96cd1 Update modules' README.md
Stick with the following style:

* Header 1 with the module name is in `lowercase`.
* Other headers are in `Sentence case`. Common header names that should
  be consistently used are `Aliases`, `Contributing`, `Functions`,
  `Settings`, and `Zsh options`.
* The names `Zim` and `Zsh` always appear capitalized, even in the
  middle of sentences.
* Prefer

      print 'code indented with 4 spaces'

  instead of
  ```zsh
  print 'code fenced by lines with three back-ticks'
  print 'unless you want syntax highlighting'
  ```
2018-12-17 14:11:16 -05:00
Eric Nielsen ab41c4484d [completion] Add options to README.md
Prefer `setopt NO_FOO` instead of `unsetopt FOO`, as former is easier to
document in the README.

Stick with the following style for the README:

* Header 1 with the module name is in `lowercase`.
* Other headers are in `Sentence case`. Common header names that should
  be consistently used are `Aliases`, `Contributing`, `Functions`,
  `Settings`, and `Zsh options`.
2018-12-15 16:54:32 -05:00
Eric Nielsen 81a52a5d7d [history] Use fc -l instead of history
`history` is equivalent to `fc -l`, and `fc` is the actual Zsh builtin.

Add the `-n` flag to suppress event numbers when listing.
2018-12-15 08:10:29 -05:00
Eric Nielsen af11392473 [history] Remove EXTENDED_HISTORY and INC_APPEND_HISTORY
as they are not required (not even recommended) to be set along with
`SHARE_HISTORY`. See zshoptions(1) on `SHARE_HISTORY`:

> This option ... also causes your typed commands to be appended to the
> history file (the latter is like specifying `INC_APPEND_HISTORY`,
> which should be turned off if this option is in effect). The history
> lines are also output with timestamps ala `EXTENDED_HISTORY` ...

Also update copy in comments and in the README. Stick with the following
style for the README:

* Header 1 with the module name is in `lowercase`.
* Other headers are in `Sentence case`. Common header names that should
  be consistently used are `Aliases`, `Functions`, `Settings`, and
  `Zsh options`.
* The names `Zim` and `Zsh` always appear capitalized, even in the
  middle of sentences.

Closes #313
2018-12-15 08:10:29 -05:00
Eric Nielsen b4ae40652d Update README.md instructions and formatting
Add a first step to explicitly start the Zsh shell, as some issues were
reported before because users were skipping this. See #214 for example.

Also mention `~/.zlogin` as part of the uninstalling process.

Use the following formatting styles:
* Headers >1 are in `Sentence case`.
* The names `Zim` and `Zsh` always appear capitalized, even in the
  middle of sentences.
* Prefer

      code indented with 4 spaces

  instead of
  ```
  code fenced by lines with three back-ticks
  ```

Closes #315
2018-12-15 07:58:03 -05:00
Eric Nielsen 7ccdcf35ee [git] Add missing items in README.md
namely, the `gfu` alias, the `git-branch-delete-interactive` function,
and a couple of commands that are shadowed.

Command `gm` was reported in #59, and `grc` was reported in #139.
2018-12-13 14:47:25 -05:00
Eric Nielsen 2004fb320b [archive] Support unarchive of multiple files
so we can do `unarchive *.tar.gz` for example.

Update README and compdef accordingly.
2018-12-07 12:55:06 -05:00
Marko Kaznovac 1e3cee4715 Don't track new files in submodules from main repo
Prevent main repo `git status` reporting submodules having new files.
New files are usually zcompiled zsh files.
There's no way to .gitignore from main repo specific files in submodules

Closes #297
2018-11-26 22:12:49 -05:00
Eric Nielsen c50a0153d2 [completion] Update submodule to version 0.29.0 2018-11-26 21:33:30 -05:00
Eric Nielsen 5fb3d4ea08 [autosuggestions] Update submodule to version v0.5.0
Main change we're interested in with this release is:
> Change `config.zsh` to keep previously set values of config vars
> https://github.com/zsh-users/zsh-autosuggestions/issues/335

Fixes #301
2018-11-26 18:22:58 -05:00
Eric Nielsen 2e3ba7996b
[archive] Allow archives in any directory
Current code will create an archive in the current directory with:

    % archive ../test.tar.gz test.*

or will complain that the following archive doesn't exist in the current
directory (given it actually exists in the parent one):

    % unarchive ../test.tar.gz

Fix that and allow archives in any directory.

Other changes:

* Use `<required_param>` instead of `[required_param]` in the usage text
* Don't explictly check if archive exists in `unarchive`, but let the
  respective tool fail with its own message

Closes #312
2018-11-24 22:45:08 -05:00
Eric Nielsen 13ba167baf [input] Put necessary double quotes back
My fault, I removed them in commit 78611457, but they are necessary.
Without them, we are getting the following error when one of the
terminfo[] values is empty:

    init.zsh:14: bad set of key/value pairs for associative array

Fixes #310
2018-11-21 17:54:24 -05:00
Eric Nielsen a05890e8b4
Use cat to concatenate files in installation
Update installation instructions in README.md to use cat. Also add blank
lines at the end (instead of beginning) of template files, since they're
prepended (not appended) to existing files.

See difference of output between print and cat (zlogin having a blank
like at the end):

    % print -rn "$(<zlogin)$(<test)"
    #
    # User configuration sourced by login shells
    #

    # Initialize zim
    [[ -s ${ZIM_HOME}/login_init.zsh ]] && source ${ZIM_HOME}/login_init.zsh# Hello world
    % cat zlogin test
    #
    # User configuration sourced by login shells
    #

    # Initialize zim
    [[ -s ${ZIM_HOME}/login_init.zsh ]] && source ${ZIM_HOME}/login_init.zsh

    # Hello world

Fixes #94. Fixes #280. Closes #300
2018-11-21 11:58:30 -05:00
Ezinwa Okpoechi 7dfd617497 [git] Make gpf alias safer
Fixes #303. Closes #304.

As a reference,
https://github.com/k88hudson/git-flight-rules/blob/master/README.md#i-want-to-delete-or-remove-my-last-commit
also recommends using --force-with-lease.
2018-11-20 18:45:03 -05:00
Eric Nielsen d259e19dd8 Don't need to use `array[@]` ouside double quotes
In  double  quotes,  array  elements  are put into separate words when
using `"${(@)array}"` or `"${array[@]}"`. See zshexpn(1).

Also according to the Zsh documentation, these forms preserve empty
elements of the array.
2018-11-19 19:43:21 -05:00
Eric Nielsen 268a570ae3 [utility] Use CLICOLOR for coloured output in BSD
instead of aliasing `ls` to `ls -G`.
CLICOLOR is detected not only by `ls`, but by `tree` too (starting with
version 1.8.0). See http://mama.indstate.edu/users/ice/tree/changes.html

It's probably more widely used by other tools too.
2018-11-19 17:13:45 -05:00
Eric Nielsen 1c23ea1604 [archive] Support archive of multiple files
not just one directory.

Also use shorter versions of the `tar` parameters, since we were using a
mixture of the short and long ones among `archive` and `unarchive`.

About not using `$` inside `(( ))`, this is what the the section
ARITHMETIC EVALUATION in zshmisc(1) says:

> Named parameters and subscripted arrays can be referenced by name
> within an arithmetic expression without using the parameter expansion
> syntax.

And according to http://www.bash2zsh.com/zsh_refcard/refcard.pdf:

> `var` (does not require `$` in front unless some substitution e.g.
> `${#var}` is needed, `$` is error if `var` is to be modified)

Closes #308
2018-11-14 20:32:37 -05:00
Eric Nielsen 2c5e7c02ea [archive] Add missing bzip2 extensions
We already had .tar.bz2, .tbz, .tbz2 and .bz2
We were missing .tar.bz and .bz

Noticed this in the pull request #308 by @Konfekt.
2018-11-14 20:20:52 -05:00
Bryan Hyshka 60b0910f6d [pacman] Add pikaur to list of AUR helpers that handle SUID
`pikaur` (https://github.com/actionless/pikaur) handles sudo
authentication itself.

Closes #302
2018-10-19 08:32:34 -05:00
Eric Nielsen 364d6b831d [prompt] steeef: Fix git-info stashed zstyle
Only define it if it's non-empty. New git-info changes will consider
zstyles to be defined even if they are empty.
2018-10-10 18:24:45 -05:00
Eric Nielsen 270b5d0390 [git-info] Simplify functions
Add missing local variable set.
Replace `>/dev/null 2>&1` by `&>/dev/null`.
Check return value of zstyle (if zero), instead of resulting string
value (if non-empty).
2018-10-02 20:02:06 -05:00
Eric Nielsen 35c5daf791
[pacman] Remove dependency from completion module
The completion module has specific code for the pacman module, and we
want to make modules independent from each other.

Plus, as far as I checked, most of the pacman wrappers/frontends are
already packaged with zsh completion out of the box. I'm not an Arch
user, but I checked the repos of the ones in
https://wiki.archlinux.org/index.php/AUR_helpers#Pacman_wrappers and
these contain zsh completion scripts:

* aura: https://github.com/aurapm/aura/blob/master/aura/doc/completions/_aura
* pacaur: https://github.com/rmarquis/pacaur/blob/master/zsh.completion
* pakku: https://github.com/kitsunyan/pakku/blob/master/completion/zsh.patch
* pikaur: https://github.com/actionless/pikaur/blob/master/packaging/usr/share/zsh/site-functions/_pikaur
* trizen: https://github.com/trizen/trizen/blob/master/zsh.completion
* yay: https://github.com/Jguer/yay/blob/master/completions/zsh

I didn't find zsh completions for the ones listed below, so I added a
compdef function for them inside the pacman module itself:

* aurman
* packer-aur
* wrapaur
* yaourt

Closes #296
2018-10-01 08:17:22 -05:00
Marko Kaznovac e5639c8fa7 [prompt] pure: Update submodule to version 1.8.0
changelog:
https://github.com/sindresorhus/pure/compare/v1.6.0...v1.8.0

Closes #298
2018-09-30 10:42:17 -05:00
Eric Nielsen 6b5d422a0a [completion] Update submodule to version 0.28.0 2018-09-28 13:20:36 -05:00
Eric Nielsen 1deef75aac [autosuggestions] Update submodule to version v0.4.3 2018-09-28 13:17:33 -05:00
Matt Hamilton 2436a6da28 [completion] Fix ssh completion for ~/.ssh/config
I think this change results in the _expected_ behavior. Users can always
override this by overriding the zstyle, as that is a benefit of using
zstyles.

Ref: https://www.zsh.org/mla/users/2015/msg00467.html

and `which _ssh_hosts`

Fixes #46. Closes #294.
2018-09-27 14:26:26 -05:00
Eric Nielsen edd4e82d8a
[ssh] Update init.zsh
based on https://stackoverflow.com/a/48509425/2654518, which is based on
http://rabexc.org/posts/pitfalls-of-ssh-agents

Current code has a few issues: depends on `SSH_AUTH_SOCK` and
`SSH_AGENT_PID` env variables, which might not be available in every
shell session; and tries to create a new socket for agent-forwarding by
checking `SSH_AUTH_SOCKET` instead of `SSH_AUTH_SOCK`.

Also, it's safer to create the env file with 066 mode and in the user
home directory.

About not using `$` inside `(( ))`, this is what the the section
ARITHMETIC EVALUATION in zshmisc(1) says:

> Named parameters and subscripted arrays can be referenced by name
> within an arithmetic expression without using the parameter expansion
> syntax.

And according to http://www.bash2zsh.com/zsh_refcard/refcard.pdf:

> `var` (does not require `$` in front unless some substitution e.g.
> `${#var}` is needed, `$` is error if `var` is to be modified)

Closes #292
2018-09-17 15:38:48 -05:00
Eric Nielsen df672688de [history-substring-search] Fix bindkey back to what works
Just binding ^[[A/^[[B does not work for some terminals, while not
binding them breaks zle widgets on other terminals. That's how crazy it
can get  :- (

Fixes #293. Fixes #295.
2018-09-17 15:32:44 -05:00
Eric Nielsen fe2cb6b9f5 [history-substring-search] Fix incompatibility with zle-line-init widget
See https://github.com/zsh-users/zsh-history-substring-search/issues/70
and comment by @molovo:

     I was already binding keys _after_ `zle-line-init`, but I'm pulling
     keycodes out of the `terminfo` module, which reports up
     (`$terminfo[kcuu1]`) as `^[0A` instead of `^[[A`. Binding `^[[A`
     manually mean up/down works with history-substring-search both
     before and after `zle-line-init`, but if I bind `$terminfo[kcuu1]`
     (`^[0a`), up/down only works *before* `zle-line-init`.

Closes #286
2018-09-16 12:01:52 -05:00