Giter Site home page Giter Site logo

jameslinus / shenv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from sathyamvellal/shenv

0.0 3.0 0.0 484 KB

A set of scripts to create custom shell environments for different activities

Home Page: http://sathyamvellal.in/shenv

License: MIT License

shenv's Introduction

Shell Environments v1.2

Why do you need this?

Let's say you are working on something and you've cd'ed to directories deep in your filesystem, you have set up your own aliases, your own functions and other shell variables which help you in executing what you are working on better. Don't you get irritated if you want to open a terminal and want to cd every time, create these functions/variables/aliases, etc? SHENV helps you in creating mini environments for each of such project directories!

Shell Support

  1. Bash

Advantages/Features

  1. You can create closed environments for different projects/activities that you do.
  2. While in an environment, if you just cd in your terminal, you won't end up in the home directory but rather in the environment's root directory which you specify.
  3. Create variables, alises and functions for an environment and don't even worry about unsetting/unaliasing them!

Instructions and Usage

For bash users

  1. Copy the envrc file bash/.bashenvrc to a location you desire and source it in your .bashrca
  2. Create a directory with the name .shenv in your home directory. This folder is used for storing all environment scripts that SHENV creates for you. If you want to change it, just set the variable SHENV_HOME at line 3 in the envrc file, to the directory you want to use as the SHENV_HOME.
  3. To create a new environment, use envcreate <name> <directory> where name is the name of the environment and directory is the absolute path to the environment's root.
  4. To start an environment, use envstart <name> where name is the name of the environment
  5. Similarly, to end the environment, use envend <name>.
  6. You can add all your custom aliases, functions, environment variables in the envinit function in <name>/shenv.sh that is created at your SHENV_HOME directory.

An example (for bash)

There are three associative arrays that SHENV uses. variables, aliases and functions.
You populate these in the envinit function (as specified above). Like so -

variables[FILE]='$ENV_ROOT/file.txt'
aliases[run]='rake generate && rake preview'
functions[mkcd]='mkdir -p $1 && cd $1' # NOTE the single quotes !!

Once you start the environment with envstart, you can use these like any other shell variable, alias or a function. Like so -

cat $FILE
run # rake generate && rake preview
mkcd foo # create directory 'foo' and cd to it

Note that SHENV is not yet able to update your PATH or CLASSPATH in an environment and later restore them.

Coming Next

  1. Update variables in an environment and restore them later. (like PATH, CLASSPATH, etc)
  2. Support for Z-Shell.

License

The MIT License (MIT)

Copyright (c) 2014, Sathyam M Vellal

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

shenv's People

Contributors

sathyamvellal avatar

Watchers

 avatar  avatar  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.