Как заставить запись истории правильно отображаться на нескольких строках

Просто export это:

#!/bin/bash

export MYVAR=myvalue
sh -c 'some_code_here'
15
13.01.2014, 00:55
1 ответ

Можно включить и отключить эту опцию в Bash с помощью shopt команда. Из страницы справочника Bash.

выборка

cmdhist   If set, bash attempts to save all lines of a multiple-line
          command in the same history entry.  This allows  easy  re-editing 
          of multiline commands.

lithist   If  set,  and the cmdhist option is enabled, multi-line commands 
          are saved to the history with embedded newlines rather than using 
          semicolon separators where possible.

Активирует опцию

$ shopt -s cmdhist
$ shopt -s lithist

Отключает опцию

$ shopt -u cmdhist
$ shopt -u lithist

Пример

$ shopt -s cmdhist
$ shopt -s lithist

Теперь, когда я работаю history:

   70  text=$(cat<<'EOF'
hello world\
foo\bar
EOF)
   71  text=$(cat<<'EOF'
hello world\
foo\bar
EOF
)
   72  ls
   73  cd IT/
...
...
  414  shopt -s lithist 
  415  history | less
  416  function blah {
  echo blah
}
  417  history | less
21
27.01.2020, 19:49

Теги

Похожие вопросы