A project bootstrapper.
- start text editor, terminal, browser, spaceship and more with single command
- support for tmux allows one to create complex terminal layouts
The script works only in Linux and Mac.
Mac OS needs gsed
. Install it with brew install gnu-sed
.
Also add following lines to .bash_profile
if not already present.
if [ -f $HOME/.bashrc ]; then
source $HOME/.bashrc
fi
Bro requires tmux 2 and above.
-
Mac
brew install tmux
-
Ubuntu
sudo apt-get install tmux
Run following commands for installation.
$ curl -o /tmp/bro https://raw.githubusercontent.com/ludbek/bro/master/install && sh /tmp/bro
BRO_STATION? ($HOME/.bro):
WORKSTATION? ($HOME/projects):
$ source ~/.bashrc
Basic project management commands.
bro create [-t template -p path] <project>
Name of the project being created.
$ bro create aproject
Template is a generic project structure which can be used to create multiple projects.
It could be a local directory or a remote git repository. If exists, it executes script
at <template-name>/tasks/setup[.ext]
.
Click here for a remote project template.
# create project from local directory template
$ bro create -t /path/to/local/template/ aproject
# create project from remote git repo
$ bro create -t [email protected]:auser/atemplate-repo.git aproject
Path where the new project will be created. By default it is created at the default directory
as specificed by environment variable WORKSTATION
.
The path could be in following formats:
-p /absolute/path/to/project
-p ~/path/to/project
-p category
Path relative to the default project directory.
# create project in default project directory
$ bro create aproject
# create project at home directory
$ bro create -p ~/ aproject
# categorize projects
# creates project at $WORKSTATION/web/blog
$ bro create -p web blog
# creates project at $WORKSTATION/web/gifhunter
$ bro create -p web gifhunter
$ bro start <project>
[...params]
Takes user to the project directory. It executes the hook at <project-dir>/tasks/init[.ext]
if it exists (More on this later).
In then context of above example, to work on the blog
project, all I have to do is hit following command.
$ bro start blog
We can pass parameters to the <project-dir>/tasks/init[.ext]
. It gives us an ability to differ the way we start a project.
$ bro start blog test
$ bro start blog open-aws-console
$bro cd <project>
It takes us to the project directory. Useful in situations where one wishes to jump to the project directory without
invoking init
hook.
$ bro list
Lists available projects.
$ bro remove <project>
Removes the project reference from bro's project index.
Once the project has been removed bro
will no longer handle it.
Removing project won't remove the project directory.
$ bro takeover <project_path> [project_name]
If there are projects which bro
did not create, one can easily hand it to bro
with this command.
# suppose there is an awesome project at ~/path/to/awesome-project
# to let 'bro' handle it, execute following command
$ bro takeover ~/path/to/awesome-project awesome-project
To takeover projects in remote repo, use create
command.
$ bro create -t [email protected]:auser/awesome-project.git awesome-project
One can quit current tmux session with bro exit
command.
All the commands are auto completed by default.
You can have some tasks to be executed inside <project_root>/tasks/init.sh
.
Any function within init.sh is automatically displayed as auto completion option.
For example, you want to run docker containers using docker-compose with the command
bro start <your_project> start-docker
so that you don't have to manually run the command.
Then the init.sh
could be:
# $1 is always the project name
# $2 is what you provide after project name in the bro start command
action=$2
start-docker () {
docker-compose up
}
# or you want to assemble your android project
assemble () {
cd android
./gradlew assembleDebug
}
$action
In this case, start-docker
and assemble
will appear as auto completion options while starting project.
bro
provides essential apis for intereacting with tmux
.
bro
requires tmux
2 or greater.
These apis are available only inside the task files.
$ structure <project>
Starts new tmux session.
$ window <name>
Creates new tmux
window.
$ run "<shell command>"
Sends given shell command to current window or pane.
$ vsplit
Vertically splits current window and selects the left pane.
$ hsplit
Horizontally splits the current window and selects the top pane.
pane <right|down>
Selects the right pane or the pane below the current pane.
focus <window>
Selects a window with given name.
connect <project>
Attach to a tmux session with given project name.
These apis are available only at <project-name>/tasks/init
script.
It must be a bash script.
#!/bin/sh
structure $project
window editor
run "nvim"
window shell
run "python manage.py shell"
window terminal
window builds
vsplit
run "python manage.py runserver"
pane right
hsplit
run "webpack --watch"
pane down
run "cd semantic"
run "gulp watch"
focus editor
connect $project