summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMitsuo Tokumori <[email protected]>2022-05-05 14:26:43 -0500
committerMitsuo Tokumori <[email protected]>2022-05-05 14:26:43 -0500
commit90f39c31e9f19bf51f0ceb9e21373dede01a4581 (patch)
tree767e3f88ba94e26db05685bab636b6aabd6a61cf
parent57e7ad1f6d8fa823155ca414bba82ca2d497504f (diff)
parentaf0561f1d902d0fb84412ca6c301152ec44407c1 (diff)
downloaddotfiles-90f39c31e9f19bf51f0ceb9e21373dede01a4581.tar.gz
dotfiles-90f39c31e9f19bf51f0ceb9e21373dede01a4581.tar.bz2
dotfiles-90f39c31e9f19bf51f0ceb9e21373dede01a4581.zip
Merge remote-tracking branch 'origin/master'
-rw-r--r--bashrc15
-rw-r--r--install.sh49
-rw-r--r--vim/vimrc25
-rw-r--r--vimrc_windows10
4 files changed, 75 insertions, 24 deletions
diff --git a/bashrc b/bashrc
index 2d1fe86..bb389e0 100644
--- a/bashrc
+++ b/bashrc
@@ -56,15 +56,18 @@ if [ -n "$force_color_prompt" ]; then
fi
fi
-if [ "$color_prompt" = yes ]; then
+# Keep the git-bash prompt if available (check if $TITLEPREFIX is set)
+# git-bash promp is helpful when browsing a git-repository
+#PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[35m\]$MSYSTEM \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]\n$'
+if [[ "$color_prompt" = yes && ! -v $TITLEPREFIX ]]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\hh\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
# Blue timestamp and italic green pwd
PS1='\[\033[34m\]|\D{%H:%M:%S}| \[\033[3;32m\][\w]\[\033[00m\]\n\$ '
-else
- # plain and simple
- PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
+#else
+# # plain and simple
+# PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
fi
-unset color_prompt force_color_prompt
+#unset color_prompt force_color_prompt
# If this is an xterm set the title to user@host:dir
case "$TERM" in
@@ -118,7 +121,7 @@ fi
# Custom prompt:
# Blue timestamp and italic green pwd
-PS1='\[\033[34m\]|\D{%H:%M:%S}| \[\033[3;32m\][\w]\[\033[00m\]\n\$ '
+#PS1='\[\033[34m\]|\D{%H:%M:%S}| \[\033[3;32m\][\w]\[\033[00m\]\n\$ '
# Environmental variables:
# less(1) config (ignore case in searchs and display raw control characters)
diff --git a/install.sh b/install.sh
index ce12503..6d794b3 100644
--- a/install.sh
+++ b/install.sh
@@ -1,26 +1,57 @@
+# THIS IS CURRENTLY EXPERIMENTAL. REVIEW AND TEST FIRST. NEVER RUN ON MAIN
+# MACHINE WITHOUT A BACKUP OF VIMFILES AND DOTFILES
+
+
# Links configuration files to the ones listed here. Backup and remove your's
-# and then run this script (while inside repo directory).
+# and then run this script while inside repo directory.
+#
+# In Windows it has to be run with git-bash.
#
# Note: This solution is lazy and causes some problems. Like not being able to
# track vim pluggins.
-# bash
-ln -s ${PWD}/profile ~/.profile
-ln -s ${PWD}/bash_aliases ~/.bash_aliases
-ln -s ${PWD}/bashrc ~/.bashrc
-ln -s ${PWD}/inputrc ~/.inputrc
+# Config
+# ======
+
+platform="linux" # linux,windows
+mode="copy" # copy,slink
+
+
+# Auto config
+# ===========
+
+# Append ~ later (bash only does 1 substitution of variables)
+if [[ $platform = "linux" ]]; then
+ VIMFILES=".vim"
+elif [[ $platform = "windows" ]]; then
+ VIMFILES="vimfiles"
+fi
+
+[[ $mode = "copy" ]] && cp_or_ln="cp"
+[[ $mode = "slink" ]] && cp_or_ln="ln -s"
+
+
+# Commands
+# ========
+
+# bash ( eval concatenates and executes)
+
+eval $cp_or_ln " ${PWD}/profile ~/.profile"
+eval $cp_or_ln " ${PWD}/bash_aliases ~/.bash_aliases"
+eval $cp_or_ln " ${PWD}/bashrc ~/.bashrc"
+eval $cp_or_ln " ${PWD}/inputrc ~/.inputrc"
# vim
# ~/.vimrc takes priority over ~/.vim/vimrc, so remove the former first
-[ -d ~/.vim/ ] || mkdir -p ~/.vim/{undo,swap,backup,plugins}
+[ -d ~/.vim/ ] || mkdir -p ~/$VIMFILES/{undo,swap,backup,plugins}
chmod 0700 ~/.vim/swap # swap files should only be readable by owner
-ln -s ${PWD}/vim/vimrc ~/.vim/vimrc
-ln -s ${PWD}/vim/fun.vim ~/.vim/fun.vim
+eval $cp_or_ln " ${PWD}/vim/vimrc ~/$VIMFILES/vimrc"
+eval $cp_or_ln " ${PWD}/vim/fun.vim ~/$VIMFILES/fun.vim"
# done
diff --git a/vim/vimrc b/vim/vimrc
index bfa4e2b..42fcc69 100644
--- a/vim/vimrc
+++ b/vim/vimrc
@@ -16,10 +16,13 @@
" Variables
" ----------------------------------------------------------------------
-set undodir=~/.vim/undo
-set viewdir=~/.vim/view
-set directory=~/.vim/swap
-set viminfofile=~/.vim/viminfo
+" Get the first directory from the list in $VIMRUNTIMEPATH
+let $VIMFILES=split(&rtp,",")[0]
+set undodir=$VIMFILES/undo
+set viminfofile=$VIMFILES/viminfo
+set viewdir=$VIMFILES/view
+set directory=$VIMFILES/swap
+set viminfofile=$VIMFILES/viminfo
" Useful
@@ -142,8 +145,8 @@ set more " Enable more-prompt for listings that don't fit in
" Mappings
" ----------------------------------------------------------------------
" F1 is help, F11 is full screen (terminal emulator)
-map <F5> :source ~/.vim/vimrc<CR>
-map <S-F5> :e ~/.vim/vimrc<CR>
+map <F5> :source $VIMFILES/vimrc<CR>
+map <S-F5> :e $VIMFILES/vimrc<CR>
map <F7> :tabp<CR>
map <F8> :tabn<CR>
map <F9> :w<CR>:make<CR>
@@ -183,6 +186,9 @@ vmap gt :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g<CR><C-L>
" output.)
" :%!jq .
+" NERDTree plugin
+nnoremap <C-t> :NERDTreeToggle<CR>
+
" Yanking and pasting
" ----------------------------------------------------------------------
@@ -214,7 +220,7 @@ set fileencoding=utf-8
" Functions
" ----------------------------------------------------------------------
" TODO: maybe replace with $runtimepath
-source ~/.vim/fun.vim
+source $VIMFILES/fun.vim
" Views and Sessions (Window layout and Line folding)
@@ -236,7 +242,7 @@ au BufWinEnter *.cpp silent loadview
" Snippets
" ----------------------------------------------------------------------
" I deleted the file accidently
-"nnoremap ,ch :-1r ~/.vim/snippets/cheader.c<CR>
+"nnoremap ,ch :-1r $VIMFILES/snippets/cheader.c<CR>
" File Browsing
@@ -278,7 +284,8 @@ inoremap <C-A> <Esc>diWi<C-R>=<C-R>"<CR>
"call plug#end()
" Other plugins
-"source ~/.vim/plugins/IndexedSearch.vim
+" I used to use IndexedSearch plugin. Functionality was incorporated into Vim
+" since Vim 8.1.1270.
set shortmess-=S
diff --git a/vimrc_windows b/vimrc_windows
new file mode 100644
index 0000000..8ce69cd
--- /dev/null
+++ b/vimrc_windows
@@ -0,0 +1,10 @@
+" Git for Windows Vim user initialization file
+" GFW uses ~/.vimrc and ~/.vim/vimrc instead of ~/_vimrc and ~/vimfiles/vimrc
+" See https://github.com/git-for-windows/git/issues/658#issuecomment-184269470
+" This file configures GFW Vim to behave like Windows Vim
+" From: https://kevinlocke.name/bits/2020/07/30/sharing-vimrc-in-git-for-windows/
+let &runtimepath = '~/vimfiles,'
+\ . join(filter(split(&runtimepath, ','), 'v:val !~? "/\\.vim"'), ',')
+\ . ',~/vimfiles/after'
+let &packpath = &runtimepath
+source ~/vimfiles/vimrc