├── .gitignore ├── .travis.yml ├── LICENSE.txt ├── Makefile ├── README.md ├── completions ├── complete.bash ├── complete.zsh └── deploy_completions.sh ├── prm.sh └── tests ├── common.bash ├── e2e.bats ├── run-tests.sh └── units.bats /.gitignore: -------------------------------------------------------------------------------- 1 | **/.DS_Store 2 | TODO.md 3 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | sudo: false 2 | language: bash 3 | 4 | addons: 5 | apt: 6 | # sources: 7 | # - 8 | packages: 9 | - build-essential 10 | - zsh 11 | 12 | cache: 13 | directories: 14 | - $HOME/bats 15 | 16 | before_install: 17 | # - export LOCAL="$(mktemp --directory --tmpdir=${TMPDIR:/tmp} local.bin.XXXXXX)" 18 | # - curl -L http://downloads.sourceforge.net/zsh/zsh-5.0.7.tar.gz | tar zx 19 | # - cd zsh-5.0.7 20 | # - ./configure --prefix=$LOCAL 21 | # - make 22 | # - make install 23 | # - cd - 24 | # - export PATH="$LOCAL/bin:$PATH" 25 | # - which zsh 26 | # - zsh --version 27 | 28 | before_script: 29 | - git clone https://github.com/sstephenson/bats.git 30 | #- cd bats 31 | #- ./install.sh /usr/local 32 | - export PATH=$PATH:$PWD/bats/bin/ 33 | 34 | script: 35 | #- bats tests/ 36 | - bash ./tests/run-tests.sh 37 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015, Eivind Arvesen 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 5 | 6 | 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 7 | 8 | 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 9 | 10 | 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. 11 | 12 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 13 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | PREFIX ?= /usr/local 2 | 3 | .PHONY: install 4 | install: 5 | @cp prm.sh $(PREFIX)/bin 6 | @echo "prm installed in $(PREFIX)/bin/prm.sh" 7 | @echo "Remember to add the following alias to your shell configuration file." 8 | @echo "alias prm=\". $(PREFIX)/bin/prm.sh\"" 9 | 10 | .PHONY: uninstall 11 | uninstall: 12 | @rm -f $(PREFIX)/bin/prm.sh 13 | @echo "prm removed from $(Prefix)/BIn" 14 | @echo "Remember to remove the alias from your shell configuration file." 15 | 16 | test: 17 | @bash tests/run-tests.sh 18 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # prm 2 | 3 | [![TravisCI Status](https://api.travis-ci.org/EivindArvesen/prm.svg)](https://travis-ci.org/EivindArvesen/prm) 4 | [![License](http://img.shields.io/badge/license-BSD3-brightgreen.svg)](https://github.com/EivindArvesen/prm/blob/master/LICENSE.txt) 5 | [![Gitter](https://img.shields.io/badge/gitter-join%20chat-brightgreen.svg)](https://gitter.im/EivindArvesen/prm) 6 | 7 | A minimal project manager for the terminal. 8 | 9 | ![Demo](https://github.com/EivindArvesen/prm/blob/demo/prm.gif) 10 | 11 | This script **must** be sourced, *not* run in a subshell. 12 | See [usage](#usage) for more information. 13 | 14 | At present, prm supports `zsh`, as well as `bash`. 15 | For more information, see the [Wiki page on Zsh support](https://github.com/EivindArvesen/prm/wiki/Zsh-support). 16 | 17 | Ostensibly, prm also [works](https://github.com/EivindArvesen/prm/issues/27) under [Cygwin](https://cygwin.com). 18 | If your `$EDITOR` is set to a program external to Cygwin (ex: Sublime Text), you 19 | might want to add `export prm_use_cygpath=true` to your `.bashrc`/`.zshrc` to send 20 | the native Windows path to the editor. 21 | 22 | Regrettably, `fish` is not supported, because of syntax incompatibilities. 23 | See [this issue](https://github.com/EivindArvesen/prm/issues/2) for some details. 24 | However, Fred Deschenes has made a [port](https://github.com/FredDeschenes/prm-fish) for `fish` that you could check out. 25 | 26 | Additionally, Michael Krieger has integrated prm into a [workflow](https://github.com/M-Krieger/prm-alfred) for [Alfred](https://www.alfredapp.com) (OS X). 27 | 28 | ## What? 29 | This program basically lets you CRUD projects. Upon activation, each projects runs its associated start-script; on deactivation, it runs the project stop-script. 30 | 31 | These bash-scripts can be used for things like changing directories, setting environment variables, cleanup, etc. 32 | 33 | There is basic prompt integration in the form of `[PROJECT] `, which can be seen in the animated .gif demo above. 34 | 35 | You can have several projects active at once in different shells, as prm associates active instances with the shell PID. 36 | Currently active projects can be listed (as described in [usage](#usage)). 37 | 38 | Dead project instances (i.e. project instances that are still active on shell exit) will be automatically deactivated the next time you run prm – without running their stop-scripts. 39 | 40 | For the motivation behind prm, please see the [Wiki page on Problem Statements and Design Goals](https://github.com/EivindArvesen/prm/wiki/Problem-Statements-and-Design-Goals). 41 | 42 | ## How? 43 | Adding and editing projects will open the associated start- and stop-scripts in your editor (as defined by the `$EDITOR` environment variable). 44 | 45 | A project start-script might for instance look something like this: 46 | 47 | ```bash 48 | # cd to project directory 49 | cd $HOME/src/Python/hello-world 50 | 51 | # activate conda env 52 | source activate hello-world 53 | 54 | # show current git status 55 | git status 56 | ``` 57 | 58 | The same project's stop-script might look like this: 59 | 60 | ```bash 61 | # deactivate conda env 62 | source deactivate hello-world 63 | 64 | # clean up 65 | rm *.log *.tmp 66 | ``` 67 | 68 | When you activate a new project, prm automatically stops any active project in the current shell. 69 | 70 | When a project is deactivated, prm changes the working directory back to the path you were originally on before starting your first project. 71 | 72 | ### Reusability 73 | If you often create projects similar to one you already have, you can load custom scripts from your projects' `start.sh` and `stop.sh`. 74 | For instance, if you'd like some python-based projects to list the number of outdated packages in their conda envs, you can save 75 | 76 | ```bash 77 | # count outdated packages in conda env 78 | echo "$((($(conda search --outdated --names-only | wc -l)-1))) outdated packages in env" 79 | ``` 80 | 81 | as e.g. `conda-list-outdated.sh` in `$PRM_DIR/.common/` (this environment variable is detailed in [usage](#usage)). 82 | You can then load this script in your start- and stop-scripts like so: 83 | 84 | ```bash 85 | prm_load conda-list-outdated 86 | ``` 87 | 88 | Additionally, if you need the name of the currently active project, this is available via the `$PRM_ACTIVE_PROJECT` environment variable. 89 | 90 | The prm command line arguments are available in start- and stop-scripts, `$3` being the first argument after your project name. 91 | 92 | All available environment variables are described on [this](https://github.com/EivindArvesen/prm/wiki/Environment-variables) Wiki page. 93 | 94 | ## Installation 95 | To install prm: `git clone https://github.com/EivindArvesen/prm.git`, or download and extract a release .zip. 96 | 97 | In order to work properly, prm **must** be sourced, *not* run in a subshell. 98 | The easiest way to do this is probably to add an alias to prm in your `~/.bashrc` (or wherever you keep your aliases), like so: 99 | 100 | ```bash 101 | alias prm=". path/to/prm.sh" 102 | ``` 103 | 104 | The technical reason for this is succinctly explained in [this](https://en.wikipedia.org/wiki/Source_(command)) Wikipedia article. 105 | 106 | You must set your `$EDITOR` env-var, e.g. 107 | 108 | ```bash 109 | export EDITOR=nano 110 | ``` 111 | 112 | in your rc-file (like `.bashrc` or `.zshrc`). 113 | 114 | ## Usage 115 | From the help option screen: 116 | 117 | ```bash 118 | usage: prm