Code Monkey home page Code Monkey logo

fish-autoenv's Introduction

fish-autoenv

An autoenv plugin for fish shell allowing excuting scripts when entering and leaving a directory

This is a fork of https://github.com/eknkc/fish-autoenv. With following changes being made:

  1. Adaption to most recent fish
  2. Bug fixes
  3. Tests added

Installation

via fisher:

fisher add pwwang/fish-autoenv

Excution on login

Due to the event loading issue before first load (#845), autoenv is not able to execute on the initial PWD when logging in until you jump to some other directory after the PS shows. To solve this problem, you need to add following to your ~/.config/fish/config.fish:

set -g __autoenv_init_pwd "" && __autoenv

to manually trigger it.

Usage

Entry and exit points

fish-autoenv sources ./.in.fish (./.env.fish) while entering a directory and ./.out.fish while leaving it.

Use cases

  • If you are in the directory /home/user/dir1 and execute cd /var/www/myproject this plugin will source following files if they exist

    /home/user/dir1/.out.fish
    /home/user/.out.fish
    /home/.out.fish
    /var/.in.fish
    /var/www/.in.fish
    /var/www/myproject/.in.fish
    
  • If you are in the directory / and execute cd /home/user/dir1 this plugin will source following files if they exist

    /home/.in.fish
    /home/user/.in.fish
    /home/user/dir1/.in.fish
    
  • If you are in the directory /home/user/dir1 and execute cd / this plugin will source following files if they exist

    /home/user/dir1/.out.fish
    /home/user/.out.fish
    /home/.out.fish
    

Examples

If you have an NLP project in /home/user/nlp, and you have installed all the tools needed via conda environment nlp. You probably want to automatically activate nlp while entering the directory and deactivate it while leaving the directory.

So you .in.fish would simply be:

conda activate nlp

And you .out.fish:

# resume whatever previous environment is
conda deactivate

fish-autoenv's People

Contributors

eknkc avatar grigorii-horos avatar maparent avatar pwwang avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.