docs: update dotfiles/bashrc

This commit is contained in:
David Thurstenson 2024-03-09 03:22:54 +00:00 committed by David Thurstenson
parent 632aeedefb
commit f3397396ce
1 changed files with 6 additions and 6 deletions

View File

@ -2,7 +2,7 @@
title: Bashrc
description: Details about how I configure my shell
published: true
date: 2024-03-08T00:01:02.134Z
date: 2024-03-09T03:22:52.743Z
tags:
editor: markdown
dateCreated: 2024-03-07T23:21:44.989Z
@ -16,13 +16,13 @@ https://git.thurstylark.com/dotfiles/bashrc/src/branch/master/.bash_profile
Bash chooses which dotfile to source based on how it gets run. If starting from a login shell, `~/.bash_profile` will get sourced, but if there's not a command in there to source your `~/.bashrc`, you may find yourself having to `exec bash` after starting bash. This can be fixed by adding the following line to your `~/.bash_profile`:
```
```bash
[ -f ~/.bashrc ]( -f ~/.bashrc .md) && . ~/.bashrc
```
I also use `~/.bash_profile` for setting numlock while in a tty:
```
```bash
case $(tty) in /dev/tty[0-9]*)
setleds -D +num * (numlock for X is set in ~/.xinitrc)
;;
@ -43,21 +43,21 @@ I'm not going in to detail about every line, but I'll hilight the important part
First off, if we're not running bash interactively, there's no use for any of the rest of this, so just skip it.
```
```bash
# If not running interactively, don't do anything
[ $- != *i* ]( $- != *i* .md) && return
```
Another cool option is actually built in to bash: If you call for a directory without any command before it, just `cd` into that directory.
```
```bash
# If a directory is given without any command, CD into it.
shopt -s autocd
```
This is where all the other utilities, aliases, and functions get pulled in. Anything in `~/.bashrc.d/` ending in `.bash` will get pulled in.
```
```bash
for f in ~/.bashrc.d/*.bash; do source "$f"; done
```