I have a command to get the docker root directory as follows:
$ docker info | grep "Docker Root Dir: " | awk '{print $NF}'
/mnt/blah/docker-data
Which works fine. But, when I attempt to set an environment variable using this command the terminal won't accept any more commands and gives out a weird error:
$ DOCKER_ROOT_DIR=$(docker info | grep "Docker Root Dir: " | awk '{print $NF}')
~ $ DOCKER_ROOT_DIR=$(docker info | grep "Docker Root Dir: " | awk '{print $NF}')
docker:~: command not found
~ $ : command not found
~ $ : command not found
~ $
I can't type any commands and ENTER or ^C results in : command not found
.
What silly thing have I done wrong?
Answer:
~ $ trap
trap -- '' SIGTSTP
trap -- '' SIGTTIN
trap -- '' SIGTTOU
trap -- 'trap_handler $BASH_COMMAND' DEBUG
~ $ echo "$PS1"
\[\e]0;\u@\h: \w\a\]${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\[\033[00m\]\[\033[01;34m\]\w\[\033[00m\] \$ \[\e]2;echo:~\a\]
~ $ echo "$PROMPT_COMMAND"
~ $
~ $ declare -f trap_handler
trap_handler ()
{
LAST_CMD=`echo "$1"`;
NICE_PWD=`pwd | sed 's/\/home\/rowead/~/'`;
set-title $LAST_CMD:$NICE_PWD
}
```
# function to set terminal title
function set-title(){
if [[ -z "$ORIG" ]]; then
ORIG=$PS1
fi
TITLE="\[\e]2;$*\a\]"
if [ -n "${VIRTUAL_ENV}" ]; then
venv=`basename "${VIRTUAL_ENV}"`
PS1=($venv)${ORIG}${TITLE}
else
PS1=${ORIG}${TITLE}
fi
}
trap
2echo "$PS1"
3.echo "$PROMPT_COMMAND"
declare -f trap_handler
as well, please.set-title
, now and if that uses any functions, those too, please.