0

Buildkite (ci ビルド サーバー) プロジェクトのステータスを zsh プロンプトに追加しようとしています! ステータスを取得し、次の形式でコロン区切りのファイルに入れる ruby​​ スクリプトを作成しました。

# .buildkite_status
project1: √
project2: x

√ と x は ANSI 色分けされています。

$ci_build 変数/関数を RPROMPT に追加するまで、正常に動作するプロンプトが表示されます。

現時点で私のプロンプトは次のようになります。

~/.dotfiles »                                         ± master*:3cce1cb

そして、私が望む変更後

~/.dotfiles »                                         ± master*:3cce1cb √

私が直面している問題は、ci_build の導入によってプロンプトがラップされるようになったことです。1週間ドキュメントを読んで微調整した後、私は提案がありません。これが機能することを本当に望んでいますが、正しく機能することを望んでいます。

これが問題の画像です: https://www.dropbox.com/s/ufj82ipd7bm0o30/Screenshot%202015-06-11%2016.52.11.png?dl=0

zsh.rc

build_status() {
  current_directory=$(basename $PWD)
  var=$(cat ~/.buildkite_status | grep \^$current_directory: | awk -F':' '{print $2}')
  echo -n $var | tr '\n' ' '
}

local git_formats="%{${fg_bold[yellow]}%}± %b%c%u:%.7i%{${reset_color}%}"
zstyle ':vcs_info:git*' enable git
zstyle ':vcs_info:git*' check-for-changes true
zstyle ':vcs_info:git*' get-revision true
zstyle ':vcs_info:git*' stagedstr "+"
zstyle ':vcs_info:git*' unstagedstr "*"
zstyle ':vcs_info:git*' formats "$git_formats"
zstyle ':vcs_info:git*' actionformats "%a $git_formats"

precmd() {
  vcs_info
  build_status
}

zle-keymap-select() { zle reset-prompt; }
zle -N zle-keymap-select

VI_MODE_INDICATOR="%{$fg_bold[red]%}<%{$fg[red]%}<<%{$reset_color%}"
vi_mode_prompt_info() {
  echo "${${KEYMAP/vicmd/$VI_MODE_INDICATOR}/(main|viins)/}"
}

local cwd='%{${fg_bold[green]}%}$(prompt_pwd)%{${reset_color}%}'
local usr='%{${fg[yellow]}%}$(user_hostname)%{${reset_color}%} '
local char='%(?,%F{cyan}»,%F{red}»)%f '
local git='${vcs_info_msg_0_}$(git_stash) '
local git_author='$(git author > /dev/null || echo "$(git author) ")'
local vi_mode='$(which vi_mode_prompt_info &> /dev/null && vi_mode_prompt_info) '
local bg_job='%{${fg_bold[black]}%}$(prompt_bg_job)%{${reset_color}%} '
local ci_build='%{$(build_status)%} '

PROMPT=$cwd$usr$char
RPROMPT=$vi_mode$bg_job$git_author$git$ci_build
4

1 に答える 1