Skip to content

Instantly share code, notes, and snippets.

@amcsi
Last active August 29, 2015 14:01
Show Gist options
  • Save amcsi/e5f0c44230dd1566b2c9 to your computer and use it in GitHub Desktop.
Save amcsi/e5f0c44230dd1566b2c9 to your computer and use it in GitHub Desktop.
Keeping track of Vim nesting
# This file is loaded by vim when calling :sh
# The purpose of this file is to set up PS1 to show that you are in a shell
# opened by vim.
source ~/.bashrc
export VIMEXTRA=''
if [[ -z "$VIMSHELL" ]]; then
export VIMSHELL=1
else
export VIMSHELL=`expr $VIMSHELL + 1`
export VIMEXTRA=" x$VIMSHELL"
fi
# expecting something like "Attila@Attila-PC:~/.vim (vim) (master *=)$" if within vimshell
# and expecting "Attila@Attila-PC:~/.vim (vim x2) (master *=)$" if in a vimshell within a vimshell
PS1="\u@\h:\w \[\033[01;31m\](vim$VIMEXTRA)\[\033[01;34m\]\[\033[01;33m\]\$(__git_ps1)\[\033[00m\]\$ "
# vim: set filetype=sh :
@amcsi
Copy link
Author

amcsi commented May 28, 2014

escape $(__git_ps1) so that it would be resolved on each shell prompt, instead of caching the result.

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