From b7c9132253f600b7c059daa89e19ada28826fbff Mon Sep 17 00:00:00 2001 From: Ian Beringer Date: Sun, 31 Jan 2016 19:23:51 +0100 Subject: [PATCH] add support for .desk file --- README.md | 5 +++-- desk | 8 +++++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f86ec17..b708031 100644 --- a/README.md +++ b/README.md @@ -27,7 +27,7 @@ There are no dependencies other than `bash`. Desk is explicitly tested with `bas `zsh`, and `fish`. ```sh -◲ desk 0.3.2 +◲ desk 0.4.1 Usage: @@ -40,6 +40,7 @@ Usage: List all desks along with a description. desk (.|go) [shell-args...] Activate a desk. Extra arguments are passed onto shell. + Without a name specified, it tries activating the desk specified in the ./Deskfile file. desk run Run a command within a desk's environment then exit. Think '$SHELL -c'. desk edit [desk-name] @@ -97,7 +98,7 @@ desk for doing work on a terraform repo Basically, desk just associates a shell script (`name.sh`) with a name. When you call `desk . name`, desk drops you into a shell where `name.sh` has been executed, and then desk extracts out certain comments in `name.sh` for useful -rendering. +rendering. If you call `desk .` without any desk specified, desk will look for a `Deskfile` file in the current directory and uses its content as the name. ### Installing diff --git a/desk b/desk index 781612d..401c449 100755 --- a/desk +++ b/desk @@ -8,7 +8,7 @@ DESKS="${DESK_DESKS_DIR:-$PREFIX/desks}" ## Commands cmd_version() { - echo "◲ desk 0.4.0" + echo "◲ desk 0.4.1" } @@ -27,6 +27,7 @@ Usage: List all desks along with a description. $PROGRAM (.|go) [shell-args...] Activate a desk. Extra arguments are passed onto shell. + Without a name specified, it tries activating the desk specified in the ./.desk file. $PROGRAM run Run a command within a desk's environment then exit. Think '\$SHELL -c'. $PROGRAM edit [desk-name] @@ -91,6 +92,11 @@ cmd_init() { cmd_go() { local TODESK="$1" + if [ -z "$TODESK" -a -f "${PWD}/Deskfile" ]; then + # if no desk is specified try the Deskfile file in the current directory + read TODESK < "${PWD}/Deskfile" + fi + local DESKEXT=$(get_deskfile_extension) local DESKPATH="$(find "${DESKS}/" -name "${TODESK}${DESKEXT}")"