Code Monkey home page Code Monkey logo

halloweenbash's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

halloweenbash's Issues

git-branch problem

You use a shell fucntion in PS1
But when you "cd" to a git repo dir, you need source ~/.bashrc to go the git branch display in the command prompt. and then you cd to other dir(not a git repo), and the branch is staill in the bash prompt...

Is any error in my environ (arch-linux , bash) ?
I then use PROMPT_COMMAND solve this:

export PROMPT_COMMAND='RET=$?;\
  BRANCH="";\
  ERRMSG="";\
  if [[ $RET != 0 ]]; then\
    ERRMSG=" $RET";\
  fi;\
  if git branch 2>/dev/null 1>/dev/null; then\
    BRANCH=$(git branch 2>/dev/null | grep \* |  cut -d " " -f 2);\
  fi;
  user="\[\e[0;31m\]\u"
  host="\[\e[0;32m\]\h"
  fdir="\[\e[1;34m\]\w"
  prompt="\[\e[0;31m\]\$"
  data="\[\e[0;36m\]date:$BOLD\D{%c}"
  git_branch="\[\e[0;33m\]$BRANCH\[\e[m\]"
  ter_color="\[\e[0;32m\]"
  PS1="$user@$host $fdir $prompt $data $git_branch $ter_color\n>"
  #PS1="$GREEN\u@\h $BLUE\W $CYAN$BRANCH$RED$ERRMSG \$ $LIGHT_GRAY";'

thx

ptw: awesome project !

Allow color switching intra-PS1

Like I do for my own. Just allow the color selections to get dragged into the PS1 box. This makes it easy to color branch and path names (for example) differently, so they stand out.

Advise to start with ': ' first and end with '; ' -- helps cut-n-paste

If you start $PS1 with ': ' and end with '; ' then you cut-n-paste entire command lines more easily (no need to grab from the end of the prompt).

Bonus: single-quote the rest of the PS1 to avoid glob injection.

Bonus: set PS2= to further help the cut-n-paste of long command-lines.

Bonus: add number of files dirty (modified/added/deleted in git workspace or index but not committed).

Bonus: add support for other VCSes.

I have support for Fossil, Mercurial, and git, in my shell startup. I've a set of functions for this. I like to format my prompt like this:

: vcs:project[branch]:TOP/.../basename-of-PWD[number-of-dirty-files:number-of-history-commands]%;

plus colors. See my .kshaliases. I then set PS1='$(vcs_ps1)'.

https://github.com/nicowilliams/env/blob/master/.kshaliases

Yes, ksh, I know. Not too hard to port to bash. See https://github.com/jakobi/script-archive/blob/master/cli.shell.functions/dir.shell/cd.nico_cd_for_bash_and_ksh.func for some help with writing ksh/bash compat code (also, those functions are awesome).

Escape $ so it becomes # after switching to root

When using "$ " as the end of my PS1 string on OS X, the $ doesn't change into a # after switching to root.

I have to either change it to "$ " or use single quotes around the exported PS1 string.

Character and colours

Nice work on this. Few little suggestions:

  1. Can you add the characters < > @, or to be able to just type some in?
  2. You could make the colours just so you drag them in like the other markers (maybe with interface like (red fg ->) or something to show it's red foreground from here onwards.
  3. Maybe you could categorise the items into dynamic/static/colours. eg.
    • Dynamic: hostname, dates, user, etc
    • Static: Spaces, other characters
    • Colours: start of a new colour, as above
  4. Would also be good if the items from the palette never moved, so we don't have to find them each time, and can get used to the position of the items

Really nice idea though!

Last command exit status

In my PS1, I find it useful to see the exit status of the last entered command. In order to do this, I need to define a function that dynamically changes PS1 using PROMPT_COMMAND

function exitstatus {
  if [ $? -eq 0 ]
  then
    export PS1="โœ“ $PROMPT"
  else
    export PS1="ร— $PROMPT"
  fi
}

PROMPT_COMMAND='exitstatus'

Does this seem like something worth adding to Halloween, or is the ceremony involved too much?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.