Bash configuration: Difference between revisions

From wikinotes
 
No edit summary
Line 1: Line 1:
Bash is configured in <code>~/.bashrc</code>. Any environment variables or functions you define here will be available in your interactive shell environment.
Bash is configured in <code>~/.bashrc</code>. Any environment variables or functions you define here will be available in your interactive shell environment.


= vi mode =
= Set Options =
<source lang="bash">
<blockquote>
You can set bash option
 
See docs https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin
 
* <code>-${flag}</code> set option
* <code>+${flag}</code> unset option
 
<syntaxhighlight lang="bash">
# examples
set -e            `# exit if any pipe/command fails` \
set -o  pipefail  `# pipe exitcode is last pipe in pipeline to exit w/ failure` \
</syntaxhighlight>
 
== vi mode ==
<blockquote>
<syntaxhighlight lang="bash">
set -o vi
set -o vi
bind -m vi-command 'Control-l: clear-screen'
bind -m vi-command 'Control-l: clear-screen'
bind -m vi-insert 'Control-l: clear-screen'
bind -m vi-insert 'Control-l: clear-screen'
</source>
</syntaxhighlight>
</blockquote><!-- vi mode -->
</blockquote><!-- Set Options -->

Revision as of 13:05, 13 August 2021

Bash is configured in ~/.bashrc. Any environment variables or functions you define here will be available in your interactive shell environment.

Set Options

You can set bash option

See docs https://www.gnu.org/software/bash/manual/bash.html#The-Set-Builtin

  • -${flag} set option
  • +${flag} unset option
# examples
set -e            `# exit if any pipe/command fails` \
set -o  pipefail  `# pipe exitcode is last pipe in pipeline to exit w/ failure` \

vi mode

set -o vi
bind -m vi-command 'Control-l: clear-screen'
bind -m vi-insert 'Control-l: clear-screen'