1
0
mirror of https://github.com/Tarrasch/zsh-autoenv.git synced 2024-11-22 15:30:59 +02:00
Commit Graph

78 Commits

Author SHA1 Message Date
Rob Speed
dfb5648505 Automatically upgrade v1 hashes (SHA-1) to v2 (cksum) (#55)
A new parameter is added to `_autoenv_hash_pair` to specify the version, defaulting to the latest (2). It outputs a `cksum`-based hash for version 2 and `shasum`-based for version 1.
Moves logic to check for an entry in `$AUTOENV_AUTH_FILE` into its own function (`_autoenv_authorized_pair`), as it may need to be called twice.
Modifies `_autoenv_authorized_env_file` to check for v1 entries when v2 fails.

Fixes #53. Alternative implementation to #54.
2017-01-10 12:07:39 +01:00
Daniel Hahler
398b6f4f54 Use cksum instead of sha1sum for checksums (#54)
This provides better performance, but requires you to re-authenticate all files.

Fixes https://github.com/Tarrasch/zsh-autoenv/issues/53.
2017-01-05 01:16:21 +01:00
Daniel Hahler
448ceefd3a _autoenv_hash_pair: use sha1sum (C) instead of shasum (Perl) (#52)
This improves performance.
2016-12-15 16:36:35 +07:00
Arash Rouhani
0ad53b6ee6 Better ~/.env_auth deprecation hint (#51)
Don't print the dot so it's easier to copy and paste.
2016-11-29 16:50:32 +01:00
Daniel Hahler
998c09addd Create path to non-existing auth file (#49)
This changes the tests to have the auth file in a non-existing subdir
always, as with `$HOME/.local/share` not being there already.

Fixes https://github.com/Tarrasch/zsh-autoenv/issues/48.
2016-06-16 01:45:25 +02:00
Daniel Hahler
ecf2b2961f Only source varstash lib if it's being used
I have noticed that `autostash` called an (accidentally)
defined/overwritten `stash` function.

While it's not possible to put this into a local scope, this will at
least make it less polluting by default (when autostashing is not used).

Additionally we could source it always (not just once), but then it
would only re-overwrite the function.

A better fix would be to prefix the functions explicitly, e.g.
`autoenv_autostash` etc.

Closes https://github.com/Tarrasch/zsh-autoenv/pull/42.
2016-04-28 20:44:05 +02:00
Daniel Hahler
f021750e89 _autoenv_ask_for_yes: handle/catch Ctrl-C and return 2016-03-06 20:27:15 +01:00
Daniel Hahler
8a80ba7f02 Quote assignments to pair/parent_file 2016-03-06 20:26:48 +01:00
Daniel Hahler
20046b46ba Add comment for "autoenv_debug: fix error with Zsh 5.0.5" 2015-11-18 19:28:37 +01:00
Daniel Hahler
1220d246b0 _autoenv_debug: fix error with Zsh 5.0.5
> _autoenv_debug:local:1: not valid in this context: handler:

Fixes https://github.com/Tarrasch/zsh-autoenv/issues/38.
2015-11-18 19:23:05 +01:00
Daniel Hahler
aee9baa418 Merge pull request #36 from blueyed/fix-api-vars-scope
Cleanup API/vars for enter/leave events
2015-10-10 22:35:41 +02:00
Daniel Hahler
eebdce22df Allow to limit autoenv_source_parent's upward recursion
This allows to use `autoenv_source_parent ..` to only look in the parent
directory.
2015-10-09 22:16:07 +02:00
Daniel Hahler
961190678e Cleanup API/vars for enter/leave events
The variables are local now, which makes them being handled correctly
when calling `autoenv_source_parent`.
Without this, a call to `autoenv_source_parent` overwrites the values in
the current scope.
2015-10-09 22:04:55 +02:00
Daniel Hahler
fadddf6502 Use shorter echo for newlines 2015-08-27 22:58:35 +02:00
Daniel Hahler
54b89914ff Use 'command cat'
Ref: https://github.com/Tarrasch/zsh-autoenv/pull/35#discussion_r38145031
2015-08-27 22:57:58 +02:00
Daniel Hahler
90d3b53505 Write _autoenv_check_authorized_env_file to stderr
stdout might be redirected, e.g. with "cd - >/dev/null", and this
message should appear in stderr probably anyway.

I've tried to add a test for this, by redirecting stdout in .zshenv, but
cram does not handle this well (and appears to redirect stderr to stdout
anyway).
2015-08-27 20:50:52 +02:00
Daniel Hahler
9a2660f939 Remove globals: _autoenv_source_dir, _autoenv_chpwd_prev_dir
The globals are not necessary and can cause problems with
AUTO_NAME_DIRS.

 - Use funcsourcetrace[1] instead of _autoenv_source_dir.
 - Use OLDPWD instead of _autoenv_chpwd_prev_dir.

Fixes #33.
2015-05-25 17:03:05 +02:00
Daniel Hahler
e68a914487 Change default values: .env => .autoenv.zsh etc
This changes the defaults:
 - AUTOENV_FILE_ENTER:   .env       => .autoenv.zsh
 - AUTOENV_FILE_LEAVE:   .env_leave => .autoenv_leave.zsh

`.env` is usually used only for key-value pairs for environment
settings, e.g. with foreman.  We do not want to interfere with this.

This also renames the setting/variable AUTOENV_ENV_FILENAME to
AUTOENV_AUTH_FILE, and uses the [XDG
spec](http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html#variables)
for the default location.

The new default location for the auth file will be
~/.local/share/autoenv_auth.

When the old setting is used, or the previous default exists, a warning
is given with instructions.

Fixes https://github.com/Tarrasch/zsh-autoenv/issues/31.
Closes https://github.com/Tarrasch/zsh-autoenv/pull/32.
2015-05-22 17:20:06 +02:00
Daniel Hahler
d6f37dbeb6 minor: doc for _autoenv_hash_pair 2015-05-09 18:25:32 +02:00
Arash Rouhani
928a945e99 Merge pull request #27 from blueyed/add-doc
Huge update of the README (finally)
2015-05-06 21:24:28 +02:00
Daniel Hahler
362c7fe00f Huge update of the README (finally) 2015-05-06 20:53:41 +02:00
Daniel Hahler
b0e23d29fe Change default for AUTOENV_FILE_LEAVE to .env_leave
This does not use a fake file extension (`.leave`) like with
`.env.leave`.
2015-05-06 20:28:23 +02:00
Daniel Hahler
470841ac3c Unset $autoenv_env_file when leaving
This allows to use $autoenv_env_file e.g. in your prompt to see what
.env is being used.
2015-04-24 17:36:41 +02:00
Daniel Hahler
d62fbffad3 Do not export AUTOENV_ENV_FILENAME, and use existing value 2015-04-24 17:28:09 +02:00
Daniel Hahler
e6e906e6b9 Fix _autoenv_get_file_mtime for zsh 4 (no pipefail option) 2015-04-23 19:55:21 +02:00
Daniel Hahler
fe3d479b08 minor: doc 2015-04-23 15:11:05 +02:00
Daniel Hahler
8763a5b627 Fix return value of _autoenv_source; use ': $(( .. ))'
`(( foo++ ))` returns an error in case $foo is not defined.
2015-04-23 14:39:38 +02:00
Daniel Hahler
9a010cbdf6 Do not reset the stack variables when (re)sourcing the plugin
This is meant to keep the current state when re-sourcing the shell
config (`. ~/.zshrc`).

Closes https://github.com/Tarrasch/zsh-autoenv/pull/24
2015-03-30 00:58:32 +02:00
Daniel Hahler
6fe08c3fde Improve zsh/zstat integration; also make it handle dirs 2015-01-25 19:22:52 +01:00
Daniel Hahler
e07a47f566 Merge branch 'allow-disable'
Closes: #20
2015-01-20 11:16:37 +01:00
Daniel Hahler
373e1b21fb Add support for $AUTOENV_DISABLED, which skips the chpwd hook 2015-01-20 11:16:22 +01:00
Daniel Hahler
873b9f8062 Fix symlink handling, especially for symlinks not below "env_dir" 2015-01-19 19:03:26 +01:00
Daniel Hahler
986a7609ff Do not cd in the chpwd hook
This is not really necessary, except for the convenience of being in the
.env file's directory during the hook.
But it messes around with the "cd history", e.g. `cd -`!

To reference the .env file or its directory, `$autoenv_env_file` and
`${autoenv_env_file:h}` can be used instead.
2015-01-17 20:10:41 +01:00
Daniel Hahler
1856e89365 Set autoenv_env_file in _autoenv_source 2015-01-17 16:39:04 +01:00
Daniel Hahler
685a3f16f5 Minor cleanup: centralize call to _autoenv_stack_entered_add 2015-01-17 16:38:40 +01:00
Daniel Hahler
936b5eaf77 Handle failure of loading zsh/stat 2014-12-18 19:45:48 +01:00
Daniel Hahler
020a9152b7 Fix being loaded from a function (antigen)
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/14
2014-12-11 16:22:54 +01:00
Daniel Hahler
1219d83c51 Fix autoloading of colors; just once 2014-12-10 00:09:04 +01:00
Daniel Hahler
53da60d3e3 Init arrays (see #14) 2014-12-09 23:12:38 +01:00
Daniel Hahler
5a968c8299 minor: fix debug message ordering 2014-12-09 23:10:54 +01:00
Daniel Hahler
9c829733ad tests: setup for multiple ZDOTDIRs, fix/add "setopt clobber" 2014-12-08 22:14:54 +01:00
Srijan R Shetty
027e8fb5de Create $AUTHENV_ENV_FILENAME if it does not exist 2014-12-08 21:45:13 +01:00
Daniel Hahler
e567a40592 Fixes after using setopt nounset during tests
Also add tests for unset variable with varstash.
2014-12-08 21:37:25 +01:00
Daniel Hahler
d6fbb13451 Merge pull request #12 from Tarrasch/autounstash-on-leave
Call `autounstash` automatically/always when leaving a directory
2014-12-04 13:31:56 +01:00
Daniel Hahler
b478c5463f Call autounstash automatically/always when leaving a directory 2014-12-04 13:28:48 +01:00
Daniel Hahler
1bfed02bc2 Add doc for _autoenv_deauthorize 2014-12-04 10:39:46 +01:00
Daniel Hahler
5655e26d6a Encapsulate the file name in the hash pair for stricter matching
Ref: https://github.com/Tarrasch/zsh-autoenv/pull/13#issuecomment-65559752
2014-12-04 10:35:09 +01:00
Daniel Hahler
13bb443f48 Fix _autoenv_deauthorize with regard to newline handling, add tests 2014-12-04 07:20:44 +01:00
Daniel Hahler
4cdad1d4d5 Handle missing $1 in _autoenv_hash_pair 2014-12-04 07:20:20 +01:00
Daniel Hahler
364c0fbb2a Remove underscore prefix from vars provided for .env files
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/11
2014-12-02 18:49:23 +01:00