Giter Club home page Giter Club logo

projector.sh's Introduction

projector.sh

Projects manager at the speed of light.

projector_demo.mov

E.g. using pr: Go to nobe4/projector.sh, go to nobe4/gh-edit, go back, go to cli/cli, and show the folder structure.


If you work with many projects, you can understand the struggle to keep everything organized and tidy. If you like to have one session per project, you know it can become a mess.

projector.sh replaces all the commands you would usually run to switch/manage projects, such as:

  • git clone $project
  • switch to project (cd, tmux, etc.)
  • mv path/to/$project
  • rm path/to/$project

It assumes a strong relationship between:

GitHub repo  <=> local folder <=> session

Install

That's it ๐ŸŽ‰

Requirements

Usage

Calling the script with no arguments is what you want to start with.

projector.sh

See full help in ./projector.sh or with projector.sh -h.

Switchers

To keep projector.sh as small as possible, the switching logic is decoupled and left to the reader for implementation. The default is to create a new shell in the project's directory.

Use the PR_SWITCHER environment variable to reference which switcher you want to use.

See ./switchers/ for examples. New switchers PRs are welcomed.

projector.sh's People

Stargazers

 avatar

Watchers

 avatar  avatar

projector.sh's Issues

Handle initial steps better

Because I wrote this while working on the setup, I didn't take initial setup into account.

  • Initial cloning should be blocking
  • Hide last and recent if they don't exist

Maybe projector.sh init command could do that.

Rework environment variables

Search for best practices.

But at least keep the inside variable named as the outside ones.

e.g.

- BASE_PATH="${PR_BASE_PATH:-${HOME:?}/dev}"
+ PR_BASE_PATH="${PR_BASE_PATH:-${HOME:?}/dev}"
- STATE_PATH="${PR_STATE_PATH:-${XDG_STATE_HOME:-${HOME:?}/.local/state}/pr}"
+ PR_STATE_PATH="${PR_STATE_PATH:-${XDG_STATE_HOME:-${HOME:?}/.local/state}/pr}"

Decouple from tmux

Tmux is only used in

projector.sh/projector.sh

Lines 211 to 237 in 79b3f63

update_last(){
current_session="$(tmux display-message -p '#S')"
[ "${current_session}" == "${LAST_PROJECT//[.:]/_}" ] && return
echo "${1}" > "${LAST_FILE_PATH}"
}
switch_session(){
[ "${1}" == "" ] && return
echo "${1}" >> "${HISTORY_FILE_PATH}"
# Tmux doesn't like . or : in session names as they represent window index or
# pane index.
session_name="${1//[.:]/_}"
if ! tmux has-session -t="${session_name}" 2> /dev/null; then
tmux new-session -d -s "${session_name}" -c "${BASE_PATH}/${1}"
fi
if [ "${TERM_PROGRAM}" = "tmux" ]; then
update_last "${1}"
tmux switch-client -t="${session_name}"
else
tmux attach-session -t="${session_name}"
fi
}

And it could support other ways of switching easily.

E.g.

  • use cd to move to the project's dir
  • create another terminal window
  • use kitty/iterm/... inner sessions functionality

It should provide a default and accept a script that does the switching.

The script would need PR_BASE_PATH, PR_HISTORY_FILE_PATH, PR_LAST_PROJECT, and PR_LAST_FILE_PATH in the environment and take single parameter being the new project to switch to.

Research creating a repo

projector.sh create

gh repo create should take most of the load.

Unfortunately, it doesn't seem to output the new repo.

$ gh repo create
? What would you like to do? Create a new repository on GitHub from scratch
? Repository name nobe4/test2
? Description
? Visibility Private
? Would you like to add a README file? No
? Would you like to add a .gitignore? No
? Would you like to add a license? No
? This will create "nobe4/test2" as a private repository on GitHub. Continue? Yes
โœ“ Created repository nobe4/test2 on GitHub
? Clone the new repository locally? No

Treat unknown command as a query for switch

This would mean that instead of

projector.sh s query

one can do

projector.sh query

as long as the query doesn't match any command.

Having a -- separator might also help.

Add `current` file

Currently the only way to track the current project is via the tmux session.

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.