bash.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Mon, 22 Feb 2016 12:46:36 +0200
changeset 1905 fba288d59662
parent 1346 a2fbf50a43f4
child 1912 8b81a8f0f692
permissions -rw-r--r--
Include only local subsections into TOC. This prevent duplication of TOC when build single page HTML document. Also this make unnecessary CSS hack to hide document title as top level section.

.. -*- coding: utf-8; -*-
.. include:: HEADER.rst

=======
 Bash.
=======
.. contents::
   :local:

How override PS1, PS2?
======================

When loading bash read ~/.bash_profile and ~/.bashrc.

Put at end of these files::

  PS1='\u@\H$ '

When xterm start bash - it start as non-login. So ~/.bash_profile and ~/.bashrc
didn't read. To workaround this use::

  $ xterm -e bash -i -c "mc -x"

That make bash interactive and init file was readed.

Command history.
================

Bash allow accessing to command that you type previously. There are several
options to control command history behavior. Set corresponding variables in
your ~/.bashrc file (which is read by interactive shell)::

  #   ignorespace do not save lines that start with space
  #   erasedups all previous lines matching the current line to be removed from
  #             the history list before that line is saved
  export HISTCONTROL=igrorespace:erasedups
  export HISTIGNORE=" ?cd *":"e *":"sudo mv *":"sudo rm *":"sudo cp *":"sudo mkdir *":"sudo chmod *":"sudo chown *":ls:pwd:"vlc*"

There are another options, with default values (which satisfy my needs, so
I don't put they to ~/.bashrc)::

  export HISTFILE=~/.bash_history  # where is command history stored
  export HISTFILESIZE=500          # how many lines been in $HISTFILE
  export HISTSIZE=500              # how many lines been stored in bash process

mc (GNU Midnight Commander).
----------------------------

You can also set special history rules for mc subshell in ~/.mc/bashrc file.

Bash history.
=============

  http://wiki.bash-hackers.org/scripting/bashchanges
                This article is an incomplete overview of changes to Bash over
                the time.