bash

2020-09-04 06:26

fuck ups

  1. deleted home directory

    Beware $rm -r * and root permissions in general

  2. deleted important files by overwrite

    Beware $echo “something” > file.txt! can recover with: $alias - dumps all alias definitions to stdout $declare -f - dumps all function definitions to stdout $export -p - dumps all env vars to stdout

  3. not making backups

    See #1 and #2

terminal setup

increase the font size

$ sudo echo setfont Uni3-Terminus32x16.psf.gz >> ~/.bash_profile

make using the terminal more tolerable

$ echo "set -o vi" >> ~/.bash_profile
$ sudo apt install vim
$ export EDITOR="vim"

change the keyboard configuration

$ cat /usr/share/X11/xkb/rules/xorg.lst | less
$ man keyboard

```
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="caps:escape"

BACKSPACE="guess"
```

$ sudo setupcon

record commands from a session

$ echo history | tail -n 50 >> learning\ notes.md

install ncurses

$ sudo apt-get install libncurses5-dev libncursesw5-dev

install tmux

$ sudo apt-get install tmux -y

configure tmux

```
# change the default prefix key
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix


# configure status line
set-option -g status-style bg=blue

# vim-like panel switching
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R
bind     $ swap-pane -D
bind < swap-pane -U

# vim-like window switching
unbind n
unbind p
bind -r C-h previous-window
bind -r C-l next-window

# vim-like resizing
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2

# logical splitting
bind | split-window -h
bind - split-window -v
```

Learning notes for terminal setup

Increase the font size

sudo echo setfont Uni3-Terminus32x16.psf.gz >> ~/.bash_profile

Change the keyboard configuration

cat /usr/share/X11/xkb/rules/xorg.lst | less man keyboard

```
XKBMODEL="pc105"
XKBLAYOUT="us"
XKBVARIANT=""
XKBOPTIONS="caps:escape"

BACKSPACE="guess"
```

sudo setupcon

Record these commands

echo history | tail -n 50 >> learning notes.md

Install ncurses

sudo apt-get install libncurses5-dev libncursesw5-dev

Install tmux

sudo apt-get install tmux -y

tmux configuration

```
# change the default prefix key
set-option -g prefix C-a
unbind-key C-b
bind-key C-a send-prefix


# configure status line
set-option -g status-style bg=blue

# vim-like panel switching
bind -r h select-pane -L
bind -r j select-pane -D
bind -r k select-pane -U
bind -r l select-pane -R
bind > swap-pane -D
bind < swap-pane -U

# vim-like window switching
unbind n
unbind p
bind -r C-h previous-window
bind -r C-l next-window

# vim-like resizing
bind -r H resize-pane -L 2
bind -r J resize-pane -D 2
bind -r K resize-pane -U 2
bind -r L resize-pane -R 2

# logical splitting
bind | split-window -h
bind - split-window -v
```

set -o vi :5, 10sort