Bash PS1 dissappears after history browsing I have been configuring my new fresh Arch installation. I just finished with my PS1 in Bash and realized about an error I do not know how to solve. This is the code: PS1='\n\[\e[30;44m \u@\h \]\[\e[34;45m\]\[\e[30;45m \w \]\[\e[35;46m\]\[\e[30;46m $(__git_ps1 &quot;(%s)&quot;) \]\[\e[0;36m\]\[\e[0m\]\n\[\e[0;42m \# \]\[\e[32;41m\]\[\e[0;41m \$ \]\[\e[0;31m\]\[\e[0m\] '  And I get this:  Then I continued with my config time and realized that if I use any of the upwards arrow key or downwards arrow key (to browse through history) twice, I get this:  Also this happens when doing recursive search:
bash prompt messed up on arrow up I have made some modification to my prompt with use of colors via tput.  It looks like now when I try to do an arrow up lookup after few moves up, the prompt is being cut into half, what I mean by this is:  From this:  PROD mysuer@server1.domain.com:~$ vim .bashrc   To this:  PROD mysuer@servegit rebase origin/add_pool   ctrl + c brings everything back to normal.  I have found some posts indicating that this may be due to the issue with missing escapes for [ however I don't see an issue here:  My code:  #red for prod, green for lab  COLOUR_RESET=$(tput sgr0) COLOUR_GREEN=$(tput setaf 2) COLOUR_BLUE=$(tput setaf 6) COLOUR_YELLOW=$(tput setaf 3) COLOUR_RED=$(tput setaf 1) BOLD=$(tput bold)  if [[ $HOSTNAME =~ .*\.domain.com$ ]]; then   COLOUR=$COLOUR_RED   PROMPT_TEXT="PROD" fi  if [[ $HOSTNAME =~ .*\.lab$ ]]; then   COLOUR=$COLOUR_BLUE   PROMPT_TEXT="LAB" fi   MYPROMPT="$COLOUR$BOLD$PROMPT_TEXT$COLOUR_RESET \[\u@$COLOUR$BOLD$(hostname -f)$COLOUR_RESET:\w\]\$ "  PS1=$MYPROMPT   UPDATE: @KamilMaciorowski has pointed out a similar question although it was not relating to a tput colors.
How to make putty to not break my session after some time? Is there a power saving application similar to Jupiter? I'm trying to install the Jupiter power settings app but, I read it is no longer compatible with the new kernel. Is there a similar program or a way to manage the power settings on 13.04? Undefined reference to `pow' and `floor' How do I enumerate the properties of a JavaScript object?  I actually want to list all the defined variables and their values, but I've learned that defining a variable actually creates a property of the window object. The diophantine equation $x^2+y^2=3z^2$ I tried to solve this question but without success:     Find all the integer solutions of the equation: $x^2+y^2=3z^2$   I know that if the sum of two squares is divided by $3$ then the two numbers are divided by $3$, hence if $(x,y,z)$ is a solution then $x=3a,y=3b$. I have $3a^2+3b^2=z^2$ and that implies $$ \left(\frac{a}{z}\right)^2+\left(\frac{b}{z}\right)^2=\frac{1}{3} $$ so I need to find the rational solutions of the equation $u^2+v^2=\frac{1}{3}$ and I think that there are no solutions for that because $\frac{1}{3}$ doesn't have a rational root, but I dont know how to explain it.  Thanks Difference between get "off of" and "off" I've noticed that man pages and other documents formatted by Unix utilities often use double backticks `` followed by double single quotes '' to wrap quoted phrases instead of the double quote character ". Single quotes are similarly replaced. Why is this?  Here are a couple examples, from the man page for grep:   To find all occurrences of the pattern `.Pp' at the beginning of a line:         $ grep '^\.Pp' myfile   The apostrophes ensure the entire expression is evaluated by grep instead  of by the user's shell.  The caret `^' matches the null string at the  beginning of a line, and the `\' escapes the `.', which would otherwise match  any character.   The grep utility is compliant with the IEEE Std 1003.1-2008 (``POSIX.1'')  specification. Sending signals to USB port using C I want to send a simple 5V signal to the usb port. The USB cabel's insulation will be removed and connected to a relay which is connected to an electric door system. I think I should write this code in C. Can somebody give me a hint? Today I was going through my text book exercise and got hold of the following question.     Let $X$ be a normed linear space with norm $\lVert\cdot\rVert$ and $A$ is a non empty convex subset of $X$ then prove that $\operatorname{Closure}(A)$ is also a convex subset of $X$.   I gave it a try but could not succeed. What are 'user' and 'system' times measuring in R system.time(exp) output? How to make itemize/enumerate/description environment robust to missing \item elements? Is there any way to make LaTeX tolerate empty itemize/enumerate (i.e. no \item)?  Specifically, I would welcome any package/elegant hack that would gracefully "cancel" a list if no elements are found (instead of firing up a Latex Error).  Before jumping to the obvious answer (which I expect would be something along the lines of "don't use itemize if you don't have items to put in" ;)) please consider my use-case:   I want to format remotely stored elements (say, bibliographic items), which I can only access as an XML file.  &lt;elems&gt;   &lt;bibelem&gt;&lt;title&gt;Cool result 1&lt;/title&gt;&lt;author&gt;joe&lt;/author&gt;&lt;/bibelem&gt;   &lt;bibelem&gt;&lt;title&gt;Cool result 2&lt;/title&gt;&lt;author&gt;jim&lt;/author&gt;&lt;/bibelem&gt; &lt;/elems&gt;  I have a python script that downloads/parses the XML and outputs its content in a file bib.tex as a list of Latex macros-decorated data  \BibElem{Cool result 1}{joe} \BibElem{Cool result 2}{jim}  Now, I want to grant the end-user complete control over the styling of her/his produced document, so the intended usage within Latex is something like  \documentclass{article} \begin{document}   \newcommand{\BibElem}[2]{\item {\em #1} by {#2}}   \begin{itemize}     \input{bib.tex}   \end{itemize} \end{document}    The rationale behind this design choice is that the user should be restricted as little as possible in her/his styling choices. For instance, the user may either want to display the bibelems within a list as shown in the example, or may prefer a fancy-formatted tabular. On the other hand, the user should design the latex document once, and should be able to run it regardless of the amount of data produced by the source.  Therefore, the python script cannot make any assumption regarding the context in which its latex product will be included, and it should be up to the user to deal with empty bibliographies, i.e. with empty lists. How could one possibly do that?  Update: Werner proposed a nice solution that redefines the list environment to make Latex oblivious of the fact he is currently in a list. However, this only seems to work if the empty list is the last list in the document, as revealed by the following mwa:    \documentclass{article} \makeatletter \newenvironment{myitemize}   {\itemize}   {\@newlistfalse\enditemize} \makeatother \begin{document}   % Empty Itemize   \begin{myitemize}   \end{myitemize}   % Next non-nested itemize environment (can be itemize/enumerate/description)    \begin{myitemize}     \item Arghh!   \end{myitemize} \end{document} Find the probability that a geometric random variable $X$ is an even number Wielding two weapons without "Two-Weapon Fighting" or "Dual Wielder"? We have a Barbarian on our team that very much likes to switch up his weapons; he goes from a Dwarven Hammer, to a pair of Hand-Axes, to occasionally just going bare-fisted. No issues there, he's fairly adept with all 3.  However, I have only just recently picked up on the way that he rolls his attacks for the two Hand-Axes: He rolls the first attack, adds his modifiers etc. Then he rolls the second attack, this time without modifiers, which is all well and good. But I'm not sure if this action uses his bonus action or not, or is considered a separate action (though, being a level 4 Barbarian, he only has one action per turn), or is merely part of the same action.  If we have a look at the Two-Weapon Fighting feature from the Fighter's fighting styles:     Two-Weapon Fighting   When you engage in two-weapon fighting, you can add your ability modifier to the damage of the second attack. (PHB5e p.72)   Similarly, the Dual Wielder feat also uses the Two-Weapon Fighting feat:     Dual Wielder   You master fighting with two weapons, gaining the following benefits:      ...         You can use two-weapon fighting even when the one-handed melee weapons you are wielding aren’t light. (PHB5e p.164, emphasis mine)      So; yes, this gives a bonus to the second weapon attack, but having asked a  to clarify which action this secondary weapon attack belongs to, it was determined that this uses your bonus action;     [...] the second attack requires a bonus action   So after that long winded explanation, here is the question: Without any additional feats, can you wield and use two weapons at once, and if so, how many actions does it require to make a full attack with both weapons in a turn? Why do most C programmers name variables like this:  int *myVariable;   rather than like this:  int* myVariable;   Both are valid. It seems to me that the asterisk is a part of the type, not a part of the variable name. Can anyone explain this logic? why can't i select two objects in edit mode?     I am trying to make a face from two different meshes but can't perform the action Evaluating a sequence of complex numbers: $|z_n - z_m| < \frac1{1+ |n-m|}$ Let $\{z_n\}$ be sequence of complex numbers such that   $$ |z_n - z_m| &lt; \frac{1}{1+ |n-m|} $$ for all $n,m$  Given this information, can we compute $\lim_{n \to \infty} z_n $?  Attempt:  For sure the sequence is bounded since the RHS is always $\leq 1 $. IF $z_m = 0$, then we have   $$ |z_n | &lt; 1 $$ for all $n$. I claim that the limit is $1$. How can I prove this ? Space after LaTeX commands Convert audio stream to WAV byte array in Java without temp file Given an InputStream called in which contains audio data in a compressed format (such as MP3 or OGG), I wish to create a byte array containing a WAV conversion of the input data. Unfortunately, if you try to do this, JavaSound hands you the following error:  java.io.IOException: stream length not specified   I managed to get it to work by writing the wav to a temporary file, then reading it back in, as shown below:  AudioInputStream source = AudioSystem.getAudioInputStream(new BufferedInputStream(in, 1024)); AudioInputStream pcm = AudioSystem.getAudioInputStream(AudioFormat.Encoding.PCM_SIGNED, source); AudioInputStream ulaw = AudioSystem.getAudioInputStream(AudioFormat.Encoding.ULAW, pcm); File tempFile = File.createTempFile("wav", "tmp"); AudioSystem.write(ulaw, AudioFileFormat.Type.WAVE, tempFile); // The fileToByteArray() method reads the file // into a byte array; omitted for brevity byte[] bytes = fileToByteArray(tempFile); tempFile.delete(); return bytes;   This is obviously less desirable. Is there a better way? How can I use multiple overlay effects simultaneously in Photoshop? There are 3 overlay effects available in Photoshop as layer styles: Color, Gradient and Pattern. The problem: these effects come in a strictly fixed order!  Is it possible to make a translucent Gradient Overlay over a Color Overlay using only layer styles? Or a Multiply Pattern and Color Overlays? Drawing a triangle from medians