celerystalk icon indicating copy to clipboard operation
celerystalk copied to clipboard

[Feature Request] Add Workspace Context to Prompt

Open decidedlygray opened this issue 7 years ago • 1 comments

Since scan gets executed against your current workspace, it would be nice to have that context without having to execute ./celerystalk workspace.

I'm thinking something like how virtualenv lists your venv name in the command prompt. Any idea on how difficult this would be to implement?

I took a quick peek at how virtualenv is doing it when you run the activate script. It is just customizing the PS1 variable. Here is a little example script ps1_sandbox.sh I put together that activates a workspace context then deactivates it in case it helps:

#!/bin/bash

# execute using: source ps1_sandbox.sh

# check if this script has been run by testing of the _PS1_SAVED variable is populated
# and if it is populated, restore our original prompt. otherwise customize the prompt
if ! [ -z "${_PS1_SAVED}" ] ; then
    # this is like the virtualenv "deactivate" to restore original prompt
    echo "[+] Restoring the prompt..."
    PS1="$_PS1_SAVED"
    export PS1
    unset _PS1_SAVED
else
    # save off the original so we can restore it later
    echo "[+] Changing the prompt..."
    _PS1_SAVED=$PS1
    export _PS1_SAVED
    WORKSPACE_NAME=myworkspace
    PS1="($WORKSPACE_NAME) $PS1"
    export PS1
    TEST1="test"
    export TEST1
fi

decidedlygray avatar Nov 26 '18 16:11 decidedlygray

This is an awesome suggestion. I am planning in moving to an interactive REPL which will indeed tell you your current workspace. However, I do plan to keep the CLI version around as well, so this is definitely something i want to keep in the pipeline. Thanks!

sethsec avatar Dec 10 '18 16:12 sethsec