bash.rst
author Oleksandr Gavenko <gavenkoa@gmail.com>
Wed, 20 Jul 2011 10:54:41 +0300
changeset 899 7b4265c8d324
parent 735 5c437e2d5fe1
permissions -rw-r--r--
Set fill-column as directory local var.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
899
7b4265c8d324 Set fill-column as directory local var.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 735
diff changeset
     1
-*- mode: outline; coding: utf-8; -*-
27
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     2
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     3
* How override PS1, PS2?
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     4
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     5
When loading bash read ~/.bash_profile and ~/.bashrc.
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     6
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     7
Put at end of these files
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     8
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
     9
  PS1='\u@\H$ '
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    10
221
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    11
When xterm start bash - it start as non-login. So ~/.bash_profile and ~/.bashrc
27
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    12
didn't read. To workaround this use
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    13
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    14
  $ xterm -e bash -i -c "mc -x"
99584256fa88 How override PS1, PS2.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
diff changeset
    15
276
ed6b5ae36a49 Correct spelling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 221
diff changeset
    16
That make bash interactive and init file was readed.
221
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    17
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    18
* Command history.
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    19
277
5c7e19c15332 Correct spelling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 276
diff changeset
    20
Bash allow accessing to command that you type previously. There are several
5c7e19c15332 Correct spelling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 276
diff changeset
    21
options to control command history behavior. Set corresponding variables in
5c7e19c15332 Correct spelling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 276
diff changeset
    22
your ~/.bashrc file (which is read by interactive shell):
221
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    23
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    24
  #   ignorespace do not save lines that start with space
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    25
  #   erasedups all previous lines matching the current line to be removed from
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    26
  #             the history list before that line is saved
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    27
  export HISTCONTROL=igrorespace:erasedups
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    28
  export HISTIGNORE=" ?cd *":"e *":"sudo mv *":"sudo rm *":"sudo cp *":"sudo mkdir *":"sudo chmod *":"sudo chown *":ls:pwd:"vlc*"
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    29
277
5c7e19c15332 Correct spelling.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 276
diff changeset
    30
There are another options, with default values (which satisfy my needs, so
221
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    31
I don't put they to ~/.bashrc):
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    32
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    33
  export HISTFILE=~/.bash_history  # where is command history stored
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    34
  export HISTFILESIZE=500          # how many lines been in $HISTFILE
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    35
  export HISTSIZE=500              # how many lines been stored in bash process
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    36
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    37
** mc (GNU Midnight Commander).
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    38
97171c12b447 About command history.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents: 27
diff changeset
    39
You can also set special history rules for mc subshell in ~/.mc/bashrc file.