bash.rst
changeset 1069 2a7388c5fef2
child 1334 9bf0d5a1f0cf
equal deleted inserted replaced
1068:ef5dc6d9b9a0 1069:2a7388c5fef2
       
     1 .. -*- coding: utf-8; -*-
       
     2 
       
     3 =======
       
     4  Bash.
       
     5 =======
       
     6 
       
     7 How override PS1, PS2?
       
     8 ======================
       
     9 
       
    10 When loading bash read ~/.bash_profile and ~/.bashrc.
       
    11 
       
    12 Put at end of these files::
       
    13 
       
    14   PS1='\u@\H$ '
       
    15 
       
    16 When xterm start bash - it start as non-login. So ~/.bash_profile and ~/.bashrc
       
    17 didn't read. To workaround this use::
       
    18 
       
    19   $ xterm -e bash -i -c "mc -x"
       
    20 
       
    21 That make bash interactive and init file was readed.
       
    22 
       
    23 Command history.
       
    24 ================
       
    25 
       
    26 Bash allow accessing to command that you type previously. There are several
       
    27 options to control command history behavior. Set corresponding variables in
       
    28 your ~/.bashrc file (which is read by interactive shell)::
       
    29 
       
    30   #   ignorespace do not save lines that start with space
       
    31   #   erasedups all previous lines matching the current line to be removed from
       
    32   #             the history list before that line is saved
       
    33   export HISTCONTROL=igrorespace:erasedups
       
    34   export HISTIGNORE=" ?cd *":"e *":"sudo mv *":"sudo rm *":"sudo cp *":"sudo mkdir *":"sudo chmod *":"sudo chown *":ls:pwd:"vlc*"
       
    35 
       
    36 There are another options, with default values (which satisfy my needs, so
       
    37 I don't put they to ~/.bashrc)::
       
    38 
       
    39   export HISTFILE=~/.bash_history  # where is command history stored
       
    40   export HISTFILESIZE=500          # how many lines been in $HISTFILE
       
    41   export HISTSIZE=500              # how many lines been stored in bash process
       
    42 
       
    43 mc (GNU Midnight Commander).
       
    44 ----------------------------
       
    45 
       
    46 You can also set special history rules for mc subshell in ~/.mc/bashrc file.
       
    47 
       
    48 Bash history.
       
    49 =============
       
    50 
       
    51   http://wiki.bash-hackers.org/scripting/bashchanges
       
    52                 This article is an incomplete overview of changes to Bash over
       
    53                 the time.
       
    54 
       
    55