Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Zsh support #6

Merged
merged 2 commits into from
Nov 15, 2019
Merged

Add Zsh support #6

merged 2 commits into from
Nov 15, 2019

Conversation

gamesh411
Copy link
Contributor

@gamesh411 gamesh411 commented Oct 31, 2019

Implement the necessary hook for Zsh shell support. Fixes #7.

Implement the necessary hook for Zsh shell support.
@gamesh411 gamesh411 mentioned this pull request Oct 31, 2019
@martong
Copy link

martong commented Nov 4, 2019

👍 for extending zsh

@whisperity whisperity added enhancement ✨ New feature or request integration 📦 Regards integration to different shells and environments labels Nov 4, 2019
@whisperity whisperity self-requested a review November 4, 2019 12:55
Copy link
Owner

@whisperity whisperity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm... something is wonky here.

I installed zsh in a Docker for testing:

94b373fb3634# zsh --version
zsh 5.4.2 (x86_64-ubuntu-linux-gnu)

Envprobe in itself works (after installing Python, of course), as in the configuration tool and such works, and the control file is emitted, however this line in particular which I understand should make the shell run the hook is not executed automatically.

root@94b373fb3634:~# zsh
Envprobe loaded successfully. :)
94b373fb3634# ep %
94b373fb3634# ep SOME_VAR=Value
94b373fb3634# echo $SOME_VAR

94b373fb3634# ep +PATH /Envprobe
94b373fb3634# which envprobe.py
envprobe.py not found
94b373fb3634# cat /tmp/.envprobe.$$-*/control.sh

export SOME_VAR=Value;

export PATH=/Envprobe:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin;
94b373fb3634# echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
94b373fb3634# echo -e "This isn't working??\n\n"
This isn't working??


94b373fb3634# __envprobe
94b373fb3634# ep %
! Modified: PATH
      added /Envprobe

+ Added:    SOME_VAR
     value: Value

94b373fb3634# which envprobe.py
/Envprobe/envprobe.py

Is there something extra that needs to be installed, or added to .zshrc, e.g. some configuration toggle that allows such hook commands to be run?

My test install ran in a docker with the following directives, so it's as plain as possible.

FROM ubuntu:18.04
RUN apt-get update && apt-get install --no-install-recommends git python3 zsh

RUN cd / && git clone http://github.com/gamesh411/envprobe.git Envprobe && cd Envprobe && git checkout zsh-support

COPY zshrc /root/.zshrc  # Copy the ZSHRC contents in the README.

shell/zsh.py Outdated Show resolved Hide resolved
@whisperity
Copy link
Owner

@martong

+1 for extending zsh

Did you try @gamesh411's on a live (or test) environment? I wish to know if only I'm messing something up, or the patch is fishy...

The previous solution presupposed oh-my-zsh being present and already
declaring precmd_functions as an array. The current solution does not
do this, and it works with or without oh-my-zsh being used.
@gamesh411
Copy link
Contributor Author

I have tested this updated solution with zshusers/zsh docker container image, which contains stock zsh (without oh-my-zsh), and I have also tested it with my environment (which does contain oh-my-zsh).

@gamesh411
Copy link
Contributor Author

I have also reproduced the feasibility of the solution using this configuration:
Dockerfile:

FROM ubuntu:18.04

RUN apt-get update && \
    apt-get install --no-install-recommends --assume-yes \
      ca-certificates \
      git \
      python3 \
      zsh && \
    rm -rf /var/lib/apt/lists/*

RUN cd /root && \
    git clone https://github.com/gamesh411/envprobe.git envprobe && \
    cd envprobe && \
    git checkout zsh-support && \
    rm -r .git

COPY zshrc /root/.zshrc

zshrc:

unset  ENVPROBE_CONFIG
export ENVPROBE_LOCATION=~/envprobe
export ENVPROBE_SHELL_PID=$$
eval   "$(${ENVPROBE_LOCATION}/envprobe-config.py shell zsh)"
alias  ep='envprobe'
alias  epc='envprobe-config'

@whisperity whisperity self-requested a review November 14, 2019 09:15
@whisperity whisperity merged commit f0eaf68 into whisperity:master Nov 15, 2019
@whisperity
Copy link
Owner

Thank you @gamesh411 it worked now on a clean install too. 😋

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ New feature or request integration 📦 Regards integration to different shells and environments
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support Zsh
3 participants