zpm-zsh / autoenv Goto Github PK
View Code? Open in Web Editor NEWAutoenv for zsh
License: GNU General Public License v3.0
Autoenv for zsh
License: GNU General Public License v3.0
zsh --version
zsh 5.0.2 (x86_64-redhat-linux-gnu)
This was working before. Thanks!
I use lukechilds/zsh-nvm
for lazy loading nvm, if I have nvm use
in my .env
file, and cd to the directory in a running shell, autoenv works fine. However, if I split my terminal and it opens in the same directory, the point at which the .env file is executed is 'too early', and the nvm
alias from the plugin is not yet available.
When changing to a directory whose name starts with the previous directory's name, autoenv is stuck in an infinite loop.
mkdir a
mkdir ab
cd a
cd ../ab
I noticed that this plugin (and probably others in this org) includes a link to the Zsh Plugin Standard at http://zdharma.org/Zsh-100-Commits-Club/Zsh-Plugin-Standard.html
. But that URL is defunct now. I found a newer functional URL for the standard at https://z-shell.github.io/zsh-plugin-assessor/Zsh-Plugin-Standard. Note also that it seems the standard has now changed: the recommended 0=
definition is more complex now. Just wanted to give you a heads up. See also ohmyzsh/ohmyzsh#10518.
# new shell is ok
cd Documents
# cd never returns
# new shell is ok
cd /usr
# everything is ok
cd include
# cd never returns
I have added
and this is what is reported :
in /usr/
in /usr//
in /usr///usr
in /usr///usr/usr
in /usr///usr/usr/usr
in /usr///usr/usr/usr/usr
in /usr///usr/usr/usr/usr/usr
in /usr///usr/usr/usr/usr/usr/usr
...
There is already an "autoenv" plugin as part of oh-my-zsh, so the following fails:
git clone https://github.com/horosgrisa/autoenv ~/.oh-my-zsh/custom/plugins
The solution I thought of is to rename the project. Maybe there is a better option I'm not aware of, but if not here is my proposition: https://github.com/Nagasaki45/hutoenv/commit/f67ef6b6a0f2d48eae7fc95d7f0ad20ba80ec2cf
Hi,
I have several node projects living as sub directories in one directory. I created a .in
file in this parent directory to set the PATH
.
This setup works fine if I cd
from outside of the parent directory into a project directory. But if I navigate within the project directories (which I do quite often), the script is not executed. (Which is the behavior as specified in the README.) But this means I end up with a PATH still pointing to the node_modules
of the project where I came from.
Is there a better solution without having to specify an .in
file in each project?
Thanks in advance
plugins=(git,autoenv)
Plug horosgrisa/autoenv
antigen-bundle horosgrisa/autoenv
I write this in .zshrc but
.zshrc:46: command not found: Plug
.zshrc:47: command not found: antigen-bundle
When the contents of .in
or .out
are longer than the current terminal window, bat
's pager activates, preventing the user from seeing the prompt. And when the user leaves the pager the code excerpt shown is empty, e.g.:
> WARNING
> This is the first time you are about to source "/tmp/autoenv/.in"
----------------
----------------
Are you sure you want to allow this? (y/N)
Consider adding -P
(i.e. --paging=never
) to the bat
options:
autoenv/functions/autoenv_check_and_run
Line 11 in 0dc14a4
Hello,
% cat ~/.env
echo "HOME .env"
% source ~/.zplugin/plugins/horosgrisa---autoenv/autoenv.plugin.zsh
HOME .env
HOME .env
This is my .env
file (similar as the example on README for NodeJS):
nvm use node
OLDPATH=$PATH
export PATH=`pwd`/node_modules/.bin:$PATH
When I enter to the directory I got the error this error:
> WARNING
> This is the first time you are about to source "/tmp/test/.env"
----------------
check_and_run:8: permission denied:
----------------
Are you sure you want to allow this? (y/N) y
N/A: version "N/A" is not yet installed.
You need to run "nvm install N/A" to install it before using it.
However, I'm able to source
it without problem.
I don't have idea why ๐.
Version: zsh 5.4.2 (x86_64-apple-darwin17.3.0)
Bash function arguments are passed to the sourced .env and .out scripts. For example:
โ ~ ls -a test_autoenv
. .. .env
โ ~ cat test_autoenv/.env
echo "$1"
โ ~ cd test_autoenv
/home/nagasaki45/test_autoenv/.env
โ test_autoenv
More info about this behavior can be found here
Specifically, it breaks activation and deactivation of conda environments. For example, I have a conda environment named conda_autoenv
, which usually activated and deactivated using source activate conda_autoenv
and source deactivate
. Here is the bug:
โ ~ ls -a test_autoenv
. .. .env .out
โ ~ cat test_autoenv/.env
source activate conda_autoenv
โ ~ cat test_autoenv/.out
source deactivate
โ ~ cd test_autoenv
discarding /home/nagasaki45/miniconda3/bin from PATH
prepending /home/nagasaki45/miniconda3/envs/conda_autoenv/bin to PATH
Error: too many arguments.
(conda_autoenv)โ test_autoenv cd ..
Error: too many arguments.
(conda_autoenv)โ ~
Notice environment was activated, after all. However, the deactivation failed.
A possible solution I found, based on this answer in stackoverflow, can be found at https://github.com/Nagasaki45/autoenv/tree/better_source. With the proposed solution:
โ ~ cd test_autoenv
discarding /home/nagasaki45/miniconda3/bin from PATH
prepending /home/nagasaki45/miniconda3/envs/conda_autoenv/bin to PATH
discarding /home/nagasaki45/miniconda3/envs/conda_autoenv/bin from PATH
(conda_autoenv)โ test_autoenv which python
/home/nagasaki45/miniconda3/envs/conda_autoenv/bin/python
(conda_autoenv)โ test_autoenv cd ..
discarding /home/nagasaki45/miniconda3/envs/conda_autoenv/bin from PATH
โ ~
There are still issues with this solution, which I'm unable to understand. See the 3rd line after cd to the test_autoenv directory - it looks like the environment is not working as expected. On the other hand working in that envirnment is fine, everything works as expected.
I have very simple .in
and .out
in the same directory.
% cat .in
echo 'autoenv: in'
% cat .out
echo 'autoenv: out'
%
Content of .out
never seems to be executed:
~ โฏ zsh -f -d % source ~/.local/share/zsh/bundle/zpm-zsh/colors/colors.plugin.zsh % source ~/.local/share/zsh/bundle/zpm-zsh/autoenv/autoenv.plugin.zsh % cd Sites/foo/ > WARNING > This is the first time you are about to source "/Users/user/Sites/foo/.in" ---------------- echo 'autoenv: in' ---------------- Are you sure you want to allow this? (y/N) y autoenv: in % cd .. %
ZSH version is zsh 5.8 (x86_64-apple-darwin19.3.0)
.
Maybe add a little section in README.md about alternatives, and how this plugin is different.
For a lot of modern web projects each developer keeps their respective environment variables stored locally, usually in a form of .env.local
or .env.*.local
.
Each of these files is added to .gitignore
to prevent committing stuff such as API keys or other environment variables specific to a project to the repository in a .env
, as this file is often added to the filesystem before deployment process commences.
It would be great if the plugin considered sourcing .env.*.local
or .env.local
before .env
to make sure creators of these project can benefit from this plugin while developing their software locally.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.