1
0
Fork 0
mirror of synced 2024-11-26 09:15:34 -05:00
Commit graph

468 commits

Author SHA1 Message Date
Eric Nielsen
a227f134a5
Source .zimrc twice when installing/updating
Once before installing/updating to prepare _zmodule_xargs, and once
after modules are updated, so functions and scripts can be found inside
them. Installation of Zim from scratch was failing because all modules
are empty at first.
2020-01-02 12:58:01 -05:00
Eric Nielsen
dfe35e1bfa
Generate static init.zsh script \o/
to autoloads the functions and sources the scripts, instead of executing
zimfw during startup, and having it always figuring out what do to on
the fly.

This takes out the worry about zimfw interfering with the startup time,
and allows room to add more features to it. So, zstyle was replaced by a
custom zmodule function to define the modules, with the extra ability of
allowing users to set custom fpath paths, autoloaded functions and
sourced scripts per module.
2020-01-02 12:58:01 -05:00
Eric Nielsen
109279fc59
Indent git log in zimfw update 2020-01-02 12:58:01 -05:00
Eric Nielsen
e7ba68511a
Fix git log in zimfw update not showing backtick
because it was being processed as the beginning of a escape sequence.
Using `print -R` fixes that. Probably a good idea to use it when
printing other messages that contain externally-generated output.
2020-01-02 12:58:01 -05:00
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
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
Eric Nielsen
c9d1be395d [prompt] Simplify short_pwd function
We don't need a second variable.
2018-09-13 10:10:49 -05:00
Sebastian Stammler
236eb14d59 [pacman] add yay to SUID handling AUR helpers
Closes #279
2018-08-21 02:02:46 -04:00
Eric Nielsen
903954985f [utility] Move GNU-only code down
so `lx` is defined after the general `ls` aliases, and also so we keep
the "condom" aliases were they were before commit 0dfce9e8.
2018-06-16 21:49:20 -05:00
Lucas Sunsi
4b0a6f9c7c Source syntax-highlighting after completion
syntax-highlighting should be sourced after compinit (see
https://github.com/zsh-users/zsh-syntax-highlighting#why-must-zsh-syntax-highlightingzsh-be-sourced-at-the-end-of-the-zshrc-file),
and history-substring-search should be sourced after syntax-highlighting
(see https://github.com/zsh-users/zsh-history-substring-search#usage).

Closes #276
2018-05-31 19:17:04 -05:00
Eric Nielsen
214330ddc9 [utility] The GNU ls alias is colours-related
Ops.
2018-05-24 21:09:06 -05:00
Eric Nielsen
0dfce9e8b7 [utility] Some GNU aliases are not colours-related
and they were mistakenly inside the Colours scope. Move them out of
there.

Still using the same `(( ${+commands[dircolors]} ))` test because it
works well with MacOS with coreutils installed without the `g` prefix,
for example.
2018-05-24 20:58:31 -05:00
Eric Nielsen
17b41952ce [utility] Revert "completion uses LS_COLORS for all OSTYPEs"
This reverts commit 2f0243e533.

Completion module does not depend on utility module anymore to set the
zstyle list-colors. Making modules independent from each other as much
as possible is a good thing.
2018-05-24 20:46:47 -05:00
Eric Nielsen
e70bee54f3 [completion] Update init.zsh and README.md
and use local string variable instead of "hardcoding" the string inside
`${}`.
2018-05-24 20:37:16 -05:00