質問するログイン新規登録

質問編集履歴

2

zshの設定を追加

2017/02/16 23:44

投稿

takets
takets

スコア43

title CHANGED
File without changes
body CHANGED
@@ -3,6 +3,25 @@
3
3
 
4
4
  上記urlの記事下部にある、zshで定義したtoggl_current()というtogglからタイムトラッキング情報を取得する関数が、シェルからコマンドを実施するたびに実行されて内容が更新されるようにしたい。
5
5
 
6
+ ■現在の設定(.zshrc)
7
+ toggl_current() {
8
+ local tgc="$(toggl --cache --csv current)"
9
+ local tgc_time=$(echo $tgc | grep Duration | cut -d ',' -f 2)
10
+ local tgc_dsc=$(echo $tgc | grep Description | cut -d ',' -f 2 | cut -c 1-20)
11
+ local short_tgc_dsc=$(if [ $(echo $tgc_dsc | wc -m) -lt 20 ]; then echo $tgc_dsc; else echo "${tgc_dsc}.."; fi)
12
+ if [ ! -n "$tgc_time" ]; then
13
+ echo "NoTimeEntry"
14
+ else
15
+ echo "[$tgc_time $short_tgc_dsc]"
16
+ fi
17
+ }
18
+
19
+ # プロンプトを2行で表示、時刻を表示
20
+ PROMPT="%(?.%{${fg[green]}%}.%{${fg[red]}%})%n${reset_color}@${fg[blue]}%m${reset_color}(%*%) %~ $(toggl_current)
21
+ %# "
22
+
23
+
24
+
6
25
  **■問題**
7
26
  シェルをzshに切り替えた直後はプロンプトの表示が意図通りになるが、cdやcpなどのコマンドを実施しても、toggl_current()が実行されず、プロンプトの内容が古いままとなる。
8
27
  表示を更新するには、zshを抜けてから再度zshにシェルを切り替える必要がある。

1

URLのタイトルを変更

2017/02/16 23:44

投稿

takets
takets

スコア43

title CHANGED
File without changes
body CHANGED
@@ -1,5 +1,5 @@
1
1
  **■目的**
2
- [参考URL](http://qiita.com/sachaos/items/ed06f09375b2cef55dda)
2
+ [私のCLI仕事術](http://qiita.com/sachaos/items/ed06f09375b2cef55dda)
3
3
 
4
4
  上記urlの記事下部にある、zshで定義したtoggl_current()というtogglからタイムトラッキング情報を取得する関数が、シェルからコマンドを実施するたびに実行されて内容が更新されるようにしたい。
5
5