From 2eadcd5bba9984fce3b80efc49a4c39be91185b9 Mon Sep 17 00:00:00 2001 From: Koichi Murase Date: Fri, 17 Mar 2023 02:00:42 +0900 Subject: [PATCH] edit: restore "PS1" while processing "bind -x" --- README-ja_JP.md | 3 +++ README.md | 8 +++++--- docs/ChangeLog.md | 1 + note.txt | 6 ++++++ src/edit.sh | 2 ++ 5 files changed, 17 insertions(+), 3 deletions(-) diff --git a/README-ja_JP.md b/README-ja_JP.md index de389967..58198297 100644 --- a/README-ja_JP.md +++ b/README-ja_JP.md @@ -328,6 +328,9 @@ $ cp -r ble-0.3.3 /path/to/blesh [[ ${BLE_VERSION-} ]] && ble-attach ``` +`source /path/to/ble.sh` 及び `ble-attach` を呼び出す時は、 +標準ストリーム (`stdin`, `stdout`, `stderr`) が現在のセッションの制御端末とは別の物にリダイレクトされていない様にして下さい。 +`source /path/to/ble.sh` をシェル関数の中から実行するのは避けて下さい。 この「より確実な設定」が必要になる詳細な条件については [Discussion #254 への回答 (英語)](https://github.com/akinomyoga/ble.sh/discussions/254#discussioncomment-4284757) で説明されています。 ## 1.4 初期化スクリプト `~/.blerc` について diff --git a/README.md b/README.md index db45c135..dd7672c0 100644 --- a/README.md +++ b/README.md @@ -57,8 +57,7 @@ place other module files in appropriate places, and strip code comments for shor Note: This does not involve any C/C++/Fortran compilations and generating binaries, so C/C++/Fortran compilers are not needed. Some people seem to bilindly believe that one always need to use `make` with C/C++/Fortran compilers to generate binaries. -They complain about `ble.sh`'s make process, which comes from the lack of knowledge on `make`. -One should learn the general principle of `make`. +They complain about `ble.sh`'s make process, but it comes from the lack of knowledge on the general principle of `make`. C/C++ programs in the repository is used to update the Unicode character table from the Unicode database when a new Unicode standard appears. The generated table is included in the repository: [`canvas.GraphemeClusterBreak.sh`](https://github.com/akinomyoga/ble.sh/blob/master/src/canvas.GraphemeClusterBreak.sh), @@ -308,7 +307,7 @@ The stable versions are significantly old compared to the devel version, so many ## 1.3 Set up `.bashrc` -If you want to load `ble.sh` by default in interactive sessions of `bash`, usually one can just source `ble.sh` in `~/.bashrc`, +If you want to load `ble.sh` in interactive sessions of `bash` by default, usually one can just source `ble.sh` in `~/.bashrc`, but more reliable way is to add the following codes to your `.bashrc` file: ```bash @@ -323,6 +322,9 @@ but more reliable way is to add the following codes to your `.bashrc` file: [[ ${BLE_VERSION-} ]] && ble-attach ``` +Basically, when `source /path/to/ble.sh` and `ble-attach` are performed, +standard streams (`stdin`, `stdout`, and `stderr`) should not be redirected but should be connected to the controlling TTY of the current session. +Also, please avoid calling `source /path/to/ble.sh` in shell functions. The detailed conditions that we need the above *more reliable setup* are explained in [an answer in Discussion #254](https://github.com/akinomyoga/ble.sh/discussions/254#discussioncomment-4284757). ## 1.4 User settings `~/.blerc` diff --git a/docs/ChangeLog.md b/docs/ChangeLog.md index 47ba2393..58670e8b 100644 --- a/docs/ChangeLog.md +++ b/docs/ChangeLog.md @@ -500,6 +500,7 @@ - main (`ble/bin/awk`): add workaround for macOS `awk-32` `#D1974` e2ec89c - util.hook: workaround bash-5.2 bug of nested read by `WINCH` `#D1981` a5b10e8 - edit: always adjust the terminal states with `bind -x` (reported by linwaytin) `#D1983` 5d14cf1 + - edit: restore `PS1` while processing `bind -x` (reported by adoyle-h) `#D2024` xxxxxxxx - syntax: suppress brace expansions in designated array initialization in Bash 5.3 `#D1989` 1e7b884 - progcomp: work around slow `nix` completion `#D1997` 2c1aacf - complete: suppress error messages from `_adb` (reported by mozirilla213) `#D2005` f2aa32b0 diff --git a/note.txt b/note.txt index 1f8f802f..799ee2d9 100644 --- a/note.txt +++ b/note.txt @@ -6716,6 +6716,12 @@ bash_tips 2023-03-16 + * edit: bind -x で PS1 も一時的に復元する (requested by adoyle-h) [#D2024] + https://github.com/akinomyoga/ble.sh/issues/304 + + lincheney/fzf-tab-completion で退避中の一時 PS1 が表示されるというから何か + と思ったら自分で PS1 を出力しているのだった。 + * 2023-03-06 menu-complete: 番号で選択する (requested by bkerin) [#D2023] https://github.com/akinomyoga/ble.sh/discussions/284 diff --git a/src/edit.sh b/src/edit.sh index 97401b14..d260a2fb 100644 --- a/src/edit.sh +++ b/src/edit.sh @@ -10420,9 +10420,11 @@ function ble/widget/.EDIT_COMMAND { local -x READLINE_ARGUMENT=$_ble_edit_arg ble/edit/enter-command-layout # #D1800 pair=leave-command-layout ble/widget/.hide-current-line keep-header + ble-edit/restore-PS1 ble/term/leave-for-widget builtin eval -- "$command"; local ext=$? ble/term/enter-for-widget + ble-edit/adjust-PS1 ble-edit/content/clear-arg ble/edit/leave-command-layout # #D1800 pair=enter-command-layout