diff --git a/README.md b/README.md index 26066e5..3891db5 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ If you have oh-my-zsh you can use the auto-complete plugin. This plugin is autom - `workspace -a/--add NAME`: Adds the current directory as a workspace with the name NAME. - `workspace -d/--delete NAME`: Removes the workspace with the name NAME. - `workspace -l/--list`: List all workspaces. +- `workspace -w/--which NAME`: Show workspace directory. - `workspace -h/--help`: Display the help. - `workspace -v/--version`: Display the version. - `workspace NAME`: Go to workspace NAME. diff --git a/help b/help index 7901617..1586365 100644 --- a/help +++ b/help @@ -20,6 +20,10 @@ VERSION workspace --version display version workspace -v +FINDING +workspace --which [name] show workspace directory +workspace -w [name] + SWITCHING workspace [name] go to workspace [name] workspace go to last used workspace diff --git a/version b/version index 13e69e9..612f580 100644 --- a/version +++ b/version @@ -1 +1 @@ -Workman version 1.2.4 +Workman version 1.3 diff --git a/workspace.sh b/workspace.sh index 80875af..5ce4c85 100755 --- a/workspace.sh +++ b/workspace.sh @@ -44,6 +44,15 @@ function workspace() { cat "$DIR/version" EXITCODE=0 } + + __workspaceman_which() { + if [[ -f $DIR/.$1 ]]; then + cat $DIR/.$1 + EXITCODE=0 + else + EXITCODE=1 + fi + } # Handle flags, getops breaks for functions if [[ ! -z "$1" ]] && [[ $1 =~ ^- ]]; then @@ -86,6 +95,18 @@ function workspace() { return $EXITCODE fi return $EXITCODE + + # Handle -w/--which flag + elif [[ "$1" = "-w" ]] || [[ "$1" = "--which" ]]; then + # Second parameter is required + if [[ ! -z "$2" ]]; then + __workspaceman_which $2 + else + echo "A name is required when checking a workspace directory." + EXITCODE=1 + return $EXITCODE + fi + return $EXITCODE fi # Handle all other commands (i.e, switching directory) diff --git a/workspace/_workspace b/workspace/_workspace index b43f854..8319a97 100644 --- a/workspace/_workspace +++ b/workspace/_workspace @@ -13,8 +13,10 @@ function _workspace() { - set4 \ '--list[list workspaces]' \ - set5 \ - '--help[show help]' \ + '--which[show workspace directory]:workspace:->listspaces' \ - set6 \ + '--help[show help]' \ + - set7 \ '--version[show version]' case "$state" in