bash 기록을 유지하는 방법?


9

이것이 예상되는지 모르겠지만 내 기록은 여러 세션에 저장되지 않습니다. 즉, 창을 닫으면 다시 열면 기록이 비어 있습니다. 여러 세션에서 어떻게 유지할 수 있습니까?

요청한 명령의 출력은 다음과 같습니다.

 set -o | grep history
history         on

$ grep -i history ~/.bashrc ~/.bash_profile ~/etc/bash.bashrc ~/etc/profile ~/.profile
/cygdrive/c/cygwin/home/car/.bashrc:# Make bash append rather than overwrite the history on disk
/cygdrive/c/cygwin/home/car/.bashrc:# History Options
/cygdrive/c/cygwin/home/car/.bashrc:# Don't put duplicate lines in the history.
/cygdrive/c/cygwin/home/car/.bashrc:# export PROMPT_COMMAND="history -a"
grep: /cygdrive/c/cygwin/home/car/etc/bash.bashrc: No such file or directory
grep: /cygdrive/c/cygwin/home/car/etc/profile: No such file or directory
/cygdrive/c/cygwin/home/car/.profile:if [ "x$HISTFILE" == "x/.bash_history" ]; then
/cygdrive/c/cygwin/home/car/.profile:  HISTFILE=$HOME/.bash_history

$ ls -la ~/ | grep history -> no output

$ echo $HISTFILE 
~/.bash_history
$ echo $HISTSIZE
500
$ echo $HISTFILESIZE 
500

아래 답변에 설명 된 수정 사항을 얻은 후에는 다음을 얻습니다.

grep -i hist .bashrc
# Make bash append rather than overwrite the history on disk
shopt -s histappend
# History Options
# Don't put duplicate lines in the history.
export HISTCONTROL="ignoredups"
# (added) A new shell gets the history lines from all previous shells
PROMPT_COMMAND='history -a'
# HISTIGNORE is a colon-delimited list of patterns which should be excluded.

세션간에 기록을 저장할 수 없습니다. 다음 질문을 읽었습니다.

중복 된 것으로 질문을받은 사람의 아래 답변을 포함하여 아무도 내 문제를 다루지 않는 것 같습니다.


또한 내 질문 과 여기 에 연결된 질문을 참조하십시오 . 제안 사항을 시도하고 여전히 문제가 있는지 다시 질문하십시오. 각성시, 중복으로 마감 투표.
— terdon

편집 : set -o | 그렙 역사 쇼 역사는 모두 500을 보여 에코 $ HISTFILE 쇼 ~ / .bash_history 파일, 에코, $ HISTSIZE와 $ HISTFILESIZE에 있지만 역사는 여전히 세션에 걸쳐 유지되지 않습니다
— Car981

$ HISTFILE이 ~ / .bash_history로 설정되었지만 ~에 .bash_history 파일이 없습니다. 어떻게 이럴 수있어 ?
— Car981

제발 편집 주석보다는 새로운 정보를 추가 할 수있는 질문을. 이 명령의 출력을 포함합니다 : set -o | grep history, grep -i history ~/.bashrc ~/.bash_profile ~/etc/bash.bashrc ~/etc/profile ~/.profile및 ls -la ~/ | grep history.
— terdon

특정 기록 파일을 설정하고이 줄을 ~/.bashrc:에 추가하십시오 export HISTFILE="~/history". 차이가 있습니까?
— terdon

답변:


7

글쎄, ~/.bashrc필요한 옵션이없는 것 같습니다 . 이 줄이 당신의 안에 있는지 확인하십시오 ~/.bashrc:

# Make Bash append rather than overwrite the history on disk:
shopt -s histappend
# A new shell gets the history lines from all previous shells
PROMPT_COMMAND='history -a'
# Don't put duplicate lines in the history.
export HISTCONTROL=ignoredups

여전히 작동하지 않습니다. 새 출력 결과 업데이트에 대해서는 편집을 참조하십시오.
— Car981

7

OK 나는 무엇이 잘못되었는지 알았다. 창을 닫을 수 없습니다. 정상적으로 종료하려면 '종료'를 입력해야합니다.


당신은 당신의 자신의 질문에 대답했습니다! 이것은 훌륭하지만 다른 사람들이 더 이상 답을 기대하지 않는다는 것을 알 수 있도록 표시해야합니다.
— Tiago

대답하기 어려운 대답입니다. 같은 문제가 발생하여 기록을 저장하기 위해 창을 수동으로 닫는 것은 좋지 않습니다. 종종 다른 방법으로 터미널 창을 닫고 느슨하게하고 싶지 않습니다.
— Krzysztof Bociurko
당사 사이트를 사용함과 동시에 당사의 쿠키 정책과 개인정보 보호정책을 읽고 이해하였음을 인정하는 것으로 간주합니다.
Licensed under cc by-sa 3.0 with attribution required.