Skip to content

Instantly share code, notes, and snippets.

@jamesbeedy
Last active January 19, 2017 16:52
Show Gist options
  • Select an option

  • Save jamesbeedy/4f06ffc76d8c246817d77a032b1be940 to your computer and use it in GitHub Desktop.

Select an option

Save jamesbeedy/4f06ffc76d8c246817d77a032b1be940 to your computer and use it in GitHub Desktop.
.bashrc bit for .juju_context.py
#!/bin/bash
# ~/.bashrc or ~/.profile
function show_juju_env {
local currentEnv
currentEnv=`~/.juju_context.py`
printf "%s" "$currentEnv"
}
export PS1="[\[\e[38;5;70m\]\$(show_juju_env)\[\e[0m\]] ${PS1}";
@merlijn-sebrechts
Copy link
Copy Markdown

merlijn-sebrechts commented Jan 19, 2017

This breaks line wrapping with long commands. Hidden Characters in PS1 have to be surrounded by \[ .. \]. More info: http://unix.stackexchange.com/questions/105958/terminal-prompt-not-wrapping-correctly

I didn't find a way to keep the hidden characters in the function because it breaks the functionality of \[..\]. This is a fix:

function show_juju_env {
  local currentEnv
  currentEnv=`~/.juju_context.py`
  printf "%s" "$currentEnv"
}

export PS1="[\[\e[38;5;70m\]\$(show_juju_env)\[\e[0m\]] ${PS1}";

@jamesbeedy
Copy link
Copy Markdown
Author

@galgalesh NICE!! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment