diff --git a/.bash.d/bashrc_prompt b/.bash.d/bashrc_prompt index fce21d0..0e59b1b 100644 --- a/.bash.d/bashrc_prompt +++ b/.bash.d/bashrc_prompt @@ -11,9 +11,8 @@ # git-prompt.sh 読み込み SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd) -if [ -f "${SCRIPT_DIR}/git-prompt.sh" ]; then - echo "[load] git-prompt.sh" - . "${SCRIPT_DIR}/git-prompt.sh" +if [ -f "${SCRIPT_DIR}/git-prompt-simple.sh" ]; then + . "${SCRIPT_DIR}/git-prompt-simple.sh" fi @@ -88,5 +87,5 @@ # SGR : \e[nm # # -PS1='\[\e[0m\e[36m\][\u@\h:\W$(__git_ps1 " (%s)")]$ \[\e[0m\e[37m\]' +PS1='\[\e[0m\e[36m\][\u@\h:\W$(__git_ps1 " (%s)")\e[36m]$ \[\e[0m\e[37m\]' PS2='>' diff --git a/.bash.d/bashrc_prompt b/.bash.d/bashrc_prompt index fce21d0..0e59b1b 100644 --- a/.bash.d/bashrc_prompt +++ b/.bash.d/bashrc_prompt @@ -11,9 +11,8 @@ # git-prompt.sh 読み込み SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd) -if [ -f "${SCRIPT_DIR}/git-prompt.sh" ]; then - echo "[load] git-prompt.sh" - . "${SCRIPT_DIR}/git-prompt.sh" +if [ -f "${SCRIPT_DIR}/git-prompt-simple.sh" ]; then + . "${SCRIPT_DIR}/git-prompt-simple.sh" fi @@ -88,5 +87,5 @@ # SGR : \e[nm # # -PS1='\[\e[0m\e[36m\][\u@\h:\W$(__git_ps1 " (%s)")]$ \[\e[0m\e[37m\]' +PS1='\[\e[0m\e[36m\][\u@\h:\W$(__git_ps1 " (%s)")\e[36m]$ \[\e[0m\e[37m\]' PS2='>' diff --git a/.bash.d/git-prompt-simple.sh b/.bash.d/git-prompt-simple.sh new file mode 100644 index 0000000..7957a5c --- /dev/null +++ b/.bash.d/git-prompt-simple.sh @@ -0,0 +1,36 @@ +# vim: ts=4 sw=4 sts=4 +################################################################################ +## Script : git-prompt-simple.sh +## Name : bash 設定ファイル [git 状態表示] +## Version : 0.0.1 +## Copyright : 2018-2019 Nomura Kei +## License : BSD-2-Clause +################################################################################ +[[ "$-" != *i* ]] && return +echo "[load] ${BASH_SOURCE:-$0}" + +GIT_PS1_DIR=~/.tmp/git_ps1/`tty` +GIT_PS1_ENV=${GIT_PS1_DIR}/git_ps1.env +mkdir -p ${GIT_PS1_DIR} +touch ${GIT_PS1_ENV} + +__git_ps1() { + . ${GIT_PS1_ENV} + if [ "${LAST_PWD}" != "${PWD}" ]; then + BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null) + STATUS= + if [ ! -z $BRANCH ] && [ ! -z "$(git status --short)" ]; then + STATUS=! + fi +cat < ${GIT_PS1_ENV} +BRANCH=${BRANCH} +STATUS=${STATUS} +LAST_PWD=${PWD} +EOF + fi + if [ ! -z $BRANCH ]; then + echo -n -e "\e[33m(${BRANCH}\e[31m${STATUS})" + fi +} + + diff --git a/.bash.d/bashrc_prompt b/.bash.d/bashrc_prompt index fce21d0..0e59b1b 100644 --- a/.bash.d/bashrc_prompt +++ b/.bash.d/bashrc_prompt @@ -11,9 +11,8 @@ # git-prompt.sh 読み込み SCRIPT_DIR=$(cd $(dirname ${BASH_SOURCE:-$0}); pwd) -if [ -f "${SCRIPT_DIR}/git-prompt.sh" ]; then - echo "[load] git-prompt.sh" - . "${SCRIPT_DIR}/git-prompt.sh" +if [ -f "${SCRIPT_DIR}/git-prompt-simple.sh" ]; then + . "${SCRIPT_DIR}/git-prompt-simple.sh" fi @@ -88,5 +87,5 @@ # SGR : \e[nm # # -PS1='\[\e[0m\e[36m\][\u@\h:\W$(__git_ps1 " (%s)")]$ \[\e[0m\e[37m\]' +PS1='\[\e[0m\e[36m\][\u@\h:\W$(__git_ps1 " (%s)")\e[36m]$ \[\e[0m\e[37m\]' PS2='>' diff --git a/.bash.d/git-prompt-simple.sh b/.bash.d/git-prompt-simple.sh new file mode 100644 index 0000000..7957a5c --- /dev/null +++ b/.bash.d/git-prompt-simple.sh @@ -0,0 +1,36 @@ +# vim: ts=4 sw=4 sts=4 +################################################################################ +## Script : git-prompt-simple.sh +## Name : bash 設定ファイル [git 状態表示] +## Version : 0.0.1 +## Copyright : 2018-2019 Nomura Kei +## License : BSD-2-Clause +################################################################################ +[[ "$-" != *i* ]] && return +echo "[load] ${BASH_SOURCE:-$0}" + +GIT_PS1_DIR=~/.tmp/git_ps1/`tty` +GIT_PS1_ENV=${GIT_PS1_DIR}/git_ps1.env +mkdir -p ${GIT_PS1_DIR} +touch ${GIT_PS1_ENV} + +__git_ps1() { + . ${GIT_PS1_ENV} + if [ "${LAST_PWD}" != "${PWD}" ]; then + BRANCH=$(git rev-parse --abbrev-ref HEAD 2> /dev/null) + STATUS= + if [ ! -z $BRANCH ] && [ ! -z "$(git status --short)" ]; then + STATUS=! + fi +cat < ${GIT_PS1_ENV} +BRANCH=${BRANCH} +STATUS=${STATUS} +LAST_PWD=${PWD} +EOF + fi + if [ ! -z $BRANCH ]; then + echo -n -e "\e[33m(${BRANCH}\e[31m${STATUS})" + fi +} + + diff --git a/.vimrc b/.vimrc index 9125c98..ea6a757 100644 --- a/.vimrc +++ b/.vimrc @@ -50,12 +50,12 @@ command Msys2 terminal set splitbelow -set termwinsize=7x0 set number set fileencoding=utf-8 set fileencodings=utf-8,sjis,iso-2202-jp-3,euc-jisx0213,guess,ucs-bom,ucs-2le,ucs-2 set fileformat=unix set ts=4 sw=4 sts=4 -set backupdir=/tmp/vim-backup -set undodir=/tmp/vim-backup +set backupdir=~/.tmp/vim-backup +set undodir=~/.tmp/vim-backup +set backspace=indent,eol,start