Skip to content

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

Notifications You must be signed in to change notification settings

kkalass/unix-multiprojects

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

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 (klas.kalass@freiheit.com)\"   > /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".

About

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

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages