2022年2月6日日曜日

fig のautocompleteが動かなくなったのは PROMPT_COMMANDが原因だった

 

私の環境は以下のとおり。

  • MacOS: 12.0.1
  • bash: 5.1.8 (homebrew)
  • iterm2

fig のautocompleteを利用してます。すごく便利です。
また、synth-shell でプロンプトの見栄えを変えてます。
今までは、問題なくfigが使えてたのですが、fig をアップデートしたら、autocompleteのメニューが表示されなくなりました。
色々調べたら、synth-shell が 環境変数のPROMPT_COMMANDを上書きしているのが原因だったみたい。

file: ~/.config/synth-shell/synth-shell-prompt.sh
	## ADD HOOK TO UPDATE PS1 AFTER EACH COMMAND
	## Bash provides an environment variable called PROMPT_COMMAND.
	## The contents of this variable are executed as a regular Bash command
	## just before Bash displays a prompt.
	## We want it to call our own command to truncate PWD and store it in NEW_PWD
	PROMPT_COMMAND=prompt_command_hook

これを、下記のように修正したら fig がうごくようになりました。
	## ADD HOOK TO UPDATE PS1 AFTER EACH COMMAND
	## Bash provides an environment variable called PROMPT_COMMAND.
	## The contents of this variable are executed as a regular Bash command
	## just before Bash displays a prompt.
	## We want it to call our own command to truncate PWD and store it in NEW_PWD
        local x=prompt_command_hook
	PROMPT_COMMAND="${x} ${PROMPT_COMMAND}"