.inputrc キーバインディングでの環境変数の使用

.inputrc キーバインディングでの環境変数の使用

コマンドライン.inputrcに環境変数の値を入力するキーバインディングをmyに追加したいと思います。USER

さまざまなエスケープを試しましたが、文字列は$USERその環境変数の値ではなくコマンドラインにそのまま書き込まれます。

$if mode=vi
  # Keymaps when we are in insert mode
  set keymap vi-insert

  # Insert path before mountpoint
  "C-e": "/run/media/$USER"

これを行う合理的な方法はありますか.inputrc?それとも別の方法を使用する方が良いですか.bashrc

ベストアンサー1

ユーザーmihの使用のヒントをshell-expand-line使用して、コマンドラインに環境変数の値を入力するこのソリューションを見つけることができました。

$if mode=vi
  # Keymaps when we are in insert mode
  set keymap vi-insert

  # Expand variables like ~ and $USER to their values
  "\C-a": shell-expand-line
  # Insert path before mountpoint, then expand the variable
  "\C-e": "/run/media/$USER/\C-a"

Ctrl+を押すとコマンドラインにe表示されます。/run/media/me/

おすすめ記事