xta / halloweenbash Goto Github PK
View Code? Open in Web Editor NEWCustom Bash Profile Generator
Home Page: http://xta.github.io/HalloweenBash/
Custom Bash Profile Generator
Home Page: http://xta.github.io/HalloweenBash/
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 !
When you drag a space up, you can never drag another space there, since it disappears :)
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.
Look:
I'm using "acpi" for ubuntu: Check here
temperature () { acpi -t | grep -Eo '[0-9]+.{2,4}'| awk '{print $1}' | head -2 | tail -1; }
I'd love to be able to drag/drop my current git branch into the prompt!
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).
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.
for the common user@host
Nice work on this. Few little suggestions:
Really nice idea though!
There's not an escape code for it like the others, but \$?
works fine in a "-quoted string.
Look:
I'm using this code below for ubuntu: Check here
aram () { free -m | awk '{print $4}' | head -2 | tail -1; }
You remove every item from Your Configuration
section, it seems I can no longer add a thing to it. A page reload is needed to "fix" the situation.
Btw, great work on this too. Very useful. ๐
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?
Can you pay for my now necessary ophthalmologist appointment?
Maybe you do have this feature. But I cannot figure it out on my MacBook running Chrome.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.