Code Monkey home page Code Monkey logo

unix-multiprojects's Introduction

Unix-MultiProjectS

Helper scripts and conventions to support simple switching between different project setups.

Daily Usage

The main goal of those scripts is to make my daily work easier, and to provide simple means to switch different contexts on the commandline.

Common aliases

Each of my projectspecific setup-dev-env.sh files defines the variable CSW to point to the current source working directory and the alias "cdw" to change to this current source working directory.

CSW=$HOME/proj/someproject/
alias cdw="cd $CSW"  # Change to the main (source) working directory of the current project

Shortcuts for Swichtching Context

When the multiprojects environment is setup correctly, an alias will be created for each project. If you call that alias, the project-specific setup file will be sourced and your working directory will be changed to $CSW of the named project.

	$ # Will setup my current shell for the project 'csnotes'
	$ csnotes
	$ # typing 'cdw' will now lead me to the main working directory of csnotes

Setup

0. Checkout unix-multiprojects

Checkout this project anywhere you like :-)

1. Adjust your ~/.bashrc

You will need to source the multiprojects-setup file for each new shell. I put the following in my ~/.bashrc :

	#
	# My own settings for the multiprojects setup
	#
	MP_PROJECTS_ROOT="/home/klas/Projekte"
	MP_BIN="/opt/multiprojects/bin" # set this to wherever your multiprojects checkout is

	# Initialize the multiprojects setup, will source the default project if that was set
	. "$MP_BIN"/mp-setup.sh
Note
you can even specify multiple project roots, like
»·······MP_PROJECTS_ROOT=("/home/klas/Projekte" "/home/klas/Privat/Projekte")

2. Add a "setup-dev-env.sh" file to each relevant project

For each project underneath your projects root directory you may add a separate file setup-dev-env.sh which will be sourced to read-in all your environment variables.

Example for a very simple setup-dev-env.sh:

#!/bin/bash

#
# project specific configuration
#
PROJECT_HOME="`mpFindProjectHome csnotes`"
PROJECT_DEV_BASE="$PROJECT_HOME/src/work"

# conventions, you should define those for every project
export CSW="$PROJECT_DEV_BASE"
alias cdw-csnotes="cd \"$PROJECT_DEV_BASE\""
alias cdw=cdw-csnotes

But maybe you fancy a more involved setup for your ecommerce projects, like:

#!/bin/bash

#
# project specific configuration
#
PROJECT_HOME="`mpFindProjectHome someprojectname`"
PROJECT_DEV_BASE="$PROJECT_HOME/src/work"
PROJECT_TOMCAT="$PROJECT_HOME/app/tomcat/"

# conventions, you should define those for every project
export CSW="$PROJECT_HOME/src/work"
alias cdw-someproj="cd \"$PROJECT_DEV_BASE\""
alias cdw=cdw-someproj

# further project specific variables and aliases
alias cd-someproj="cd $PROJECT_HOME"

alias cdtom="cd $PROJECT_TOMCAT"
alias eclipse-someproj="export GDK_NATIVE_WINDOWS=true; $PROJECT_HOME/local/opt/eclipse-helios/eclipse -vm /home/klas/Lokal/java/jdk/bin  -showlocation -data $PROJECT_HOME/eclipse-workspace -vmargs  -Xms768M -Xmx768M -XX:MaxPermSize=512m -Duser.name=\"Klas Kalass ([email protected])\"   > /dev/null 2>&1 </dev/zero &"

alias catalina-someproj="export CATALINA_OPTS=\"-Dfile.encoding=ISO-8859-1 -Djava.awt.headless=true\";$PROJECT_TOMCAT/bin/catalina.sh"

alias solr-someproj="export CATALINA_OPTS=\"-Dfile.encoding=ISO-8859-1 -Djava.awt.headless=true\";$PROJECT_HOME/app/solr/bin/catalina.sh"

export PATH="$PROJECT_HOME/bin:$PATH"
export ANT_OPTS="$ANT_OPTS -Xmx384M"
export JAVA_OPTS="$JAVA_OPTS  -server -Xss256k -Xms512M -Xmx768M -XX:MaxPermSize=512m"

In every new shell you open now, you will have an alias for each of your configured projects.

3. Set the default project

You will probably want to always have the environment for the project you are currently working on automatically set up on login. To achieve this, you can use the following command (only works when mp-setup.sh sourced with the correct environment vars available).

	$ mpSetDefault csnotes

Now, every shell that was not manually switched to a different project will go to the csnotes-working directory when you type "cdw".

unix-multiprojects's People

Contributors

kkalass avatar

Stargazers

 avatar

Watchers

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