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

73 Commits

Author SHA1 Message Date
Daniel Hahler
c60241f9d9
Add helper functions for $PATH manipulation (#90) 2018-09-14 03:46:43 +02:00
Daniel Hahler
2c8cfbcea8
Handle setopt shwordsplit (#89)
This uses `emulate -L zsh` (as a more broad approach to `setopt
localtoptions noshwordsplit`, or quoting things) in the entry points to
zsh-autoenv.

Fixes https://github.com/Tarrasch/zsh-autoenv/issues/75
2017-12-16 01:09:41 +01:00
Daniel Hahler
12ed110764 Optimize _autoenv_authorized_env_file
This uses Zsh directly, instead of calling grep potentially twice for a
missing entry.
2017-12-16 01:03:54 +01:00
Daniel Hahler
8d2c53e856 tests: mv ZDOTDIR.{clobber,options} 2017-12-16 00:22:26 +01:00
Daniel Hahler
b92462ff2d tests: simplify ZDOTDIR setup, remove base
This makes it easier to run tests without providing ZDOTDIR.
2017-12-16 00:22:26 +01:00
Daniel Hahler
f9112d7459
tests: cleanup test_full (#86)
Changes tests/varstash_export.t to use `$TESTSHELL` provided by cram.
2017-12-15 23:24:12 +01:00
Daniel Hahler
51c7421f10
_autoenv_hash_pair: do not use a subshell (#81)
As a side-effect this should fix
https://github.com/Tarrasch/zsh-autoenv/issues/39 in case it was still
an issue after all.
2017-12-15 15:59:11 +01:00
Rob Speed
84bb32a403 FIX: Compatibility with macOS/FreeBSD (#82)
Removed use of `sed` due to its behavior differing between GNU Coreutils and FreeBSD.
2017-12-15 15:58:39 +01:00
Daniel Hahler
468fa71d15
Fix tests: match $CRAMTMP more losely (#78)
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/76.
2017-12-14 00:53:53 +01:00
Daniel Hahler
d6bfdff968
Fix (auto)unstashing when being sourced from a subdir (#79)
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/77.
2017-12-14 00:53:25 +01:00
Rob Speed
7e0d027b21 _autoenv_get_file_upwards: do not dereference symlinks (#73)
This prevents issues where autoenv scripts use $0. When a shell enters the directory holding the autoenv scripts, it works as expected with $0 being the path to the symlink. However, if the shell enters one of its child directories the path to the script is dereferenced, and $0 is instead the path to the symlink's target.

From `man 1 zshexpn`:

> A – Turn a file name into an absolute path as the 'a' modifier does, and then pass  the  result  through  the  realpath(3) library function to resolve symbolic links.

Note: Symlinks are dereferenced elsewhere for authorization, so that behavior is unchanged.
2017-11-02 02:40:45 +01:00
Daniel Hahler
bdc6967fc9 Set varstash_dir for "leave" event (#72)
Fixes https://github.com/Tarrasch/zsh-autoenv/issues/45.
2017-10-18 00:31:43 +02:00
Daniel Hahler
32598b5850 Minor cleanup 2017-08-18 15:27:32 +02:00
Daniel Hahler
0f92983d1e Add autoenv-edit function to edit current env files (#68) 2017-08-11 14:15:46 +02:00
Daniel Hahler
b90d2c4f80 _autoenv_get_file_upwards: handle relative paths
If `$look_from` is `.` the resulting file patch will be relative.
2017-08-11 10:27:20 +02:00
Daniel Hahler
4aeb48a02e Fix use of local in while loop. (#66)
For some reason it did not fail on Travis when only pushing the test
first?!

Also adds punctuation to already-stashed msg.
2017-05-16 22:58:25 +02:00
Daniel Hahler
0169704cdb tests: fixes for noclobber (#62) 2017-04-23 22:11:55 +02:00
Daniel Hahler
41e0daa35f tests: test_autoenv_add_to_env: create auth file parent dir (#59)
This is required when running single test files, e.g. only cwd.t.
2017-04-23 14:24:17 +02:00
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
d51b8ecccc Add a test for autostashing aliases (#44)
Ref: https://github.com/Tarrasch/zsh-autoenv/issues/43
2016-11-29 21:46:50 +07: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
b68bedc562 Add tests/ZDOTDIR.shwordsplit 2015-11-18 19:25:07 +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
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
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
fd54606830 tests: streamline ZDOTDIR layout, AUTOENV_ENV_FILENAME via setup
Without this, a new subshell would reset the env authentication file.
2015-04-24 17:33:09 +02:00
Daniel Hahler
433693f5c6 Cleanup tests/varstash_export.t 2015-04-23 17:57:56 +02:00
Daniel Hahler
7699fe6aba tests: rename setup.sh to setup.zsh 2015-04-23 16:03:21 +02:00
Daniel Hahler
ebef4c2613 tests: define/use $TEST_SOURCE_AUTOENV
This handled (re)loading autoenv for
ZDOTDIR=tests/ZDOTDIR.loadviafunction.
2015-04-23 16:00:15 +02:00
Daniel Hahler
c4e388980e varstash: add support for exported variables in subshells 2015-04-23 15:11:40 +02:00
Daniel Hahler
5cf1e01b28 tests: setup.sh: export TEST_AUTOENV_PLUGIN_FILE 2015-04-23 14:40:26 +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
e8372e9cdf tests: setopt errexit during setup
This is meant to prevent accidentally overwriting your auth file when
running / changing the tests.
2015-03-15 22:16:12 +01:00
Daniel Hahler
b3a56f449f Merge pull request #22 from Tarrasch/improve-and-test-zstat-integration
Improve and test zstat integration
2015-01-26 14:08:25 +01:00
Daniel Hahler
88e602e367 tests: setup.sh: doc / more verbose 2015-01-25 19:50:27 +01:00
Daniel Hahler
5cb689875e tests: abort if setup fails!
Otherwise the user's auth file might get removed.
2015-01-25 19:48:56 +01:00
Daniel Hahler
5d65371786 Test env for invalid zsh module_path, where zsh/zstat fails 2015-01-25 19:22:52 +01:00
Daniel Hahler
6fe08c3fde Improve zsh/zstat integration; also make it handle dirs 2015-01-25 19:22:52 +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
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
9c829733ad tests: setup for multiple ZDOTDIRs, fix/add "setopt clobber" 2014-12-08 22:14:54 +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