소스 검색

Move prompt settings into their own files

Also just realised that using the value of `$PWD` is the same as running
`pwd`, but more better.
Weiyi Lou 9 년 전
부모
커밋
c6927c4aa6
4개의 변경된 파일20개의 추가작업 그리고 23개의 파일을 삭제
  1. 10 3
      shell/bash/prompt.bash
  2. 0 9
      shell/bashrc
  3. 10 0
      shell/zsh/prompt.zsh
  4. 0 11
      shell/zshrc

+ 10 - 3
shell/bash/prompt.bash

@@ -1,4 +1,11 @@
-# Functions used in building the command prompt.
+# Command Prompt
+#
+#     [host]  directory  gitinfo  jobinfo
+#     user -
+#
+PROMPT_COMMAND='PS1="
+${FG[6]}[\h]  ${FG[3]}$(shortcwd)$(__gitp "  %s")$(getajob)
+${FG[5]}\u - $cReset"'
 
 # Display suspended/backgrounded job count, if any.
 function getajob() {
@@ -8,8 +15,8 @@ function getajob() {
 
 # Display up to 3 segments of the current working directory.
 function shortcwd() {
-  local folder=$(pwd) fld='[^/]*'
-  folder=${folder/$HOME/"~"}
+  local fld='[^/]*'
+  folder=${PWD/$HOME/"~"}
   folder=$(echo $folder | sed 's|.*/\('$fld'/'$fld'/'$fld'\)|\1|')
   printf "$folder"
 }

+ 0 - 9
shell/bashrc

@@ -9,15 +9,6 @@ for file in ~/dotfiles/shell/bash/*.bash; do
   source $file
 done
 
-# Command Prompt
-#
-#     [host]  directory  gitinfo  jobinfo
-#     user -
-#
-PROMPT_COMMAND='PS1="
-${FG[6]}[\h]  ${FG[3]}$(shortcwd)$(__gitp "  %s")$(getajob)
-${FG[5]}\u - $cReset"'
-
 [[ -r ~/.bashrc.local ]] && source ~/.bashrc.local
 
 [ -f ~/.fzf.bash ] && source ~/.fzf.bash

+ 10 - 0
shell/zsh/prompt.zsh

@@ -0,0 +1,10 @@
+# Command Prompt
+#
+#     [host]  directory  gitinfo  jobinfo
+#     user -                                           vimode time histeventno
+#
+setopt PROMPT_SUBST
+PROMPT='
+$FG[6][%m]  $FG[3]%3~$(__gitp "  %s")%(1j.  $FG[63][jobs]: $FG[1]%j.)
+$FG[5]%n - $cReset'
+RPROMPT='$(vimode) $cReset%T $FG[7]%h$cReset'

+ 0 - 11
shell/zshrc

@@ -4,17 +4,6 @@ for file in ~/dotfiles/shell/zsh/*.zsh; do
   source $file
 done
 
-# Command Prompt
-#
-#     [host]  directory  gitinfo  jobinfo
-#     user -                                           vimode time histeventno
-#
-setopt PROMPT_SUBST
-PROMPT='
-$FG[6][%m]  $FG[3]%3~$(__gitp "  %s")%(1j.  $FG[63][jobs]: $FG[1]%j.)
-$FG[5]%n - $cReset'
-RPROMPT='$(vimode) $cReset%T $FG[7]%h$cReset'
-
 [[ -r ~/.zshrc.local ]] && source ~/.zshrc.local
 
 [ -f ~/.fzf.zsh ] && source ~/.fzf.zsh