I'm currently using git-for-windows-sdk, with Bash 3.1.33(1)-release. I experience quite annoying and buggy behavior when I scroll up and press key up: Console doesn't scroll back to bottom, just shows the prompt and starts overwriting output.
Clearing helps just for the currently shown area, after outputting goes next, there is still buffered output.
How to reproduce:
Output something longer than 1 screen.
Scroll up.
Press arrow up key.
Expected behavior:
Bash scrolls down and shows prompt.
Current behavior:
Bash stays on the screen and shows prompt on the last line. Then overwrites buffered output.
Actually, I tried to investigate this behavior a little bit. And I realized, that it's affected by PS1/PROMPT setting. Color escapes and new lines have some role in it, but I was unable to define it.
the default git-bash prompt setting doesn't produce this wrong behavior:
export PROMPT_COMMAND='__git_ps1 "\n\[\033[33m\]\w\[\033[0m\]\[\033[32m\]" "\[\033[0m\]\n$ "'
just removing the new line produces wrong behavior:
export PROMPT_COMMAND='__git_ps1 "\n\[\033[33m\]\w\[\033[0m\]\[\033[32m\]" "\[\033[0m\]$ "'
however, one line prompt without colors doesn't produce wrong behavior:
export PROMPT_COMMAND='__git_ps1 "\w" " \$ "'
For better understanding see this screencast: http://screencast.com/t/vqItWFSoR
Related
For some reason whenever I shrink my terminal window to be shorter than my prompt, it will start appending my prompts on to one another. Below are all the lines in my .bashrc file that are concerned with the PS1 environment variable
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u#\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]'
and
export PS1="$PS1\$(__git_ps1)\[\033[00m\]\$ "
The problem I'm talking about can be seen in the following screenshots:
Whenever I enter a terminal command in vim (e.g., !echo hello), I am momentarily kicked out to view the result of that terminal command and then prompted with Press ENTER or type command to continue. This is a bit jarring. I would like to stay within vim and with the command output printed out at the bottom.
I know vim :read will take the terminal output and actually put it into my buffer, but that is not what I am looking to do. Here is some reading if you are interested in a tangent.
It looks like when I run vim in Screen I get what I am looking for, but I am trying to get this to work with tmux and the stock Mac terminal.
After a ton of research, probably too much, I got it! It looks like vim will send commands to the terminal, which in turn defines the behavior of how the terminal commands are processed from vim. Put this into your .vimrc file:
set t_ti= t_te= " show results from terminal commands within vim!
From what I understand, this just makes sure to send nothing to the terminal, which yields my desired results!
Side note: the above addition to your .vimrc file will also prevent the vim buffer from clearing when exiting vim (e.g., :wq). I am okay with this! It is kind of nice sometimes to see what you were just working on :).
I have customised my ksh shell prompt. It is as follows:
export PS1=$'\E[31;1m$(date +%H:%M:%S) \E[32;1m${PWD##*/} \E[33;1m$ \E[0m'
Sometimes when I press backspace the cursor will jump to the very beginning of the window and overwrite the prompt. I heard this can be a problem with escaping the colours however the examples I have seen online resemble what I have above.
Any idea what can be causing this?
I was editing .bash_profile and after I saved it ,terminal shows nothing.How can I reset it to previous mode.This is how it looks now.
I changed the value of PS1 variable.I don't have any knowledge about terminal.Please help.
The PS1 environment variable defines what the bash prompt looks like. The default varies among distros, but is generally something like this:
PS1='\h:\W \u\$ '
The bash manpage has an explanation of PS1 values under the heading "Prompting".
You can apply PS1 values to your current terminal session by pressing Control+C several times, then pasting in the line of code above and pressing return or enter. That should get your environment behaving normally long enough to edit your bash profile unless something else is wrong.
If something else is wrong with your profile, and bash is completely broken, you can temporarily use a different shell (one that doesn't care about your bash_profile) with the "New Command..." option in Terminal.app's file menu. When prompted for a command, enter /bin/zsh. You should then get a usable terminal window which you can use to edit or move your .bash_profile.
Whenever I start screen, it changes the title of the terminal window to 'screen'. Can I prevent that and have the window title remain what it would be if I hadn't run my command under screen?
More specifically, I'd like gnome-terminal to display the name of the buffer I'm editing in vim. I can do this by adding set title to my .vimrc. Now when I run vim, the buffer name (along with some other information), shows up in the title of gnome-terminal. When I start screen and run vim, the title changes to 'screen'.
I've looked at the following page:
http://beautifulpixels.blogspot.co.at/2012/01/automatic-screen-window-titles-in-bash.html
But the suggested solution places the window title in the screen status line. I also tried adding this:
case $TERM in
screen*)
# http://dtfm.tumblr.com/post/7193076007/the-sweetest-screenrc-hack-ever
SCREENTITLE='\[\ek\e\\\]\[\ek\W\e\\\]'
;;
*)
SCREENTITLE=''
;;
esac
TITLEBAR='\[\e]0;\a\]'
export PS1="${SCREENTITLE}${TITLEBAR}[\u#\h \W]\$ "
To my .bashrc, but this only sets the window title to the current directory. Even if I run vim, the window title remains the current working directory. This is not the case if I run it outside of screen.
Any ideas?
Although I didn't exactly solve it, demure's comment enticed me to check out tmux. Using that I was able to put the following line:
autocmd BufReadPost,FileReadPost,BufNewFile * call system("tmux rename-window '" . expand("%:p:~") . " - VIM'")
In my .vimrc file and I get the effect I wanted in the first place (except, of course, now I'm using tmux).
References:
tmux tabs with name of file open in vim
How can I expand the full path of the current file to pass to a command in Vim?