author | Oleksandr Gavenko <gavenkoa@gmail.com> |
Sat, 10 Feb 2018 01:36:16 +0200 | |
changeset 2229 | 1a0b6597e594 |
parent 2228 | 837f1337c59b |
child 2256 | 0ac7d9a3d658 |
permissions | -rw-r--r-- |
1069 | 1 |
.. -*- coding: utf-8; -*- |
2 |
||
3 |
======= |
|
4 |
Bash. |
|
5 |
======= |
|
1346
a2fbf50a43f4
Fix: Has no 'contents::' directive.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1334
diff
changeset
|
6 |
.. contents:: |
1905
fba288d59662
Include only local subsections into TOC. This prevent duplication of
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1346
diff
changeset
|
7 |
:local: |
1069 | 8 |
|
9 |
How override PS1, PS2? |
|
10 |
====================== |
|
11 |
||
12 |
When loading bash read ~/.bash_profile and ~/.bashrc. |
|
13 |
||
14 |
Put at end of these files:: |
|
15 |
||
16 |
PS1='\u@\H$ ' |
|
17 |
||
18 |
When xterm start bash - it start as non-login. So ~/.bash_profile and ~/.bashrc |
|
19 |
didn't read. To workaround this use:: |
|
20 |
||
21 |
$ xterm -e bash -i -c "mc -x" |
|
22 |
||
23 |
That make bash interactive and init file was readed. |
|
24 |
||
25 |
Command history. |
|
26 |
================ |
|
27 |
||
28 |
Bash allow accessing to command that you type previously. There are several |
|
29 |
options to control command history behavior. Set corresponding variables in |
|
30 |
your ~/.bashrc file (which is read by interactive shell):: |
|
31 |
||
32 |
# ignorespace do not save lines that start with space |
|
33 |
# erasedups all previous lines matching the current line to be removed from |
|
34 |
# the history list before that line is saved |
|
35 |
export HISTCONTROL=igrorespace:erasedups |
|
36 |
export HISTIGNORE=" ?cd *":"e *":"sudo mv *":"sudo rm *":"sudo cp *":"sudo mkdir *":"sudo chmod *":"sudo chown *":ls:pwd:"vlc*" |
|
37 |
||
38 |
There are another options, with default values (which satisfy my needs, so |
|
39 |
I don't put they to ~/.bashrc):: |
|
40 |
||
41 |
export HISTFILE=~/.bash_history # where is command history stored |
|
42 |
export HISTFILESIZE=500 # how many lines been in $HISTFILE |
|
43 |
export HISTSIZE=500 # how many lines been stored in bash process |
|
44 |
||
45 |
mc (GNU Midnight Commander). |
|
46 |
---------------------------- |
|
47 |
||
48 |
You can also set special history rules for mc subshell in ~/.mc/bashrc file. |
|
49 |
||
50 |
Bash history. |
|
51 |
============= |
|
52 |
||
2228
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
53 |
http://wiki.bash-hackers.org/scripting/bashchanges |
837f1337c59b
Removed indentation that compiled into <blockquote>.
Oleksandr Gavenko <gavenkoa@gmail.com>
parents:
1912
diff
changeset
|
54 |
This article is an incomplete overview of changes to Bash over the time. |
1069 | 55 |
|
56 |