Chapter 6. Configure shells

Do this now because we'll be using shells for the rest and it's annoying to use default configuration shells.

  1. Configure user shell

    Copy from Dropbox (except that we don't get Dropbox until Chapter 11, Obtain the encrypted cloud , so copy from source in the sidebar and maybe go back later to double-check.) cp ~/Dropbox/Basic/new_machine/linux/misc/.bash_aliases ~/Dropbox/Basic/new_machine/linux/misc/.bashrc ~/ Or paste in emacs ~/.bash_aliases ~/.bashrc

    Note

    ~/.bashrc source

    # ~/.bashrc: executed by bash(1) for non-login shells.
    # see /usr/share/doc/bash/examples/startup-files (in the package bash-doc)
    # for examples
    
    # If not running interactively, don't do anything
    case $- in
        *i*) ;;
          *) return;;
    esac
    
    # don't put duplicate lines or lines starting with space in the history.
    # See bash(1) for more options
    HISTCONTROL=ignoreboth
    
    # append to the history file, don't overwrite it
    shopt -s histappend
    
    # for setting history length see HISTSIZE and HISTFILESIZE in bash(1)
    HISTSIZE=1000
    HISTFILESIZE=2000
    
    # check the window size after each command and, if necessary,
    # update the values of LINES and COLUMNS.
    shopt -s checkwinsize
    
    # make less more friendly for non-text input files, see lesspipe(1)
    [ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)"
    
    # set variable identifying the chroot you work in (used in the prompt below)
    if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then
        debian_chroot=$(cat /etc/debian_chroot)
    fi
    
    # Alias definitions.
    # You may want to put all your additions into a separate file like
    # ~/.bash_aliases, instead of adding them here directly.
    # See /usr/share/doc/bash-doc/examples in the bash-doc package.
    
    if [ -f ~/.bash_aliases ]; then
        . ~/.bash_aliases
    fi
    
    # enable programmable completion features (you don't need to enable
    # this, if it's already enabled in /etc/bash.bashrc and /etc/profile
    # sources /etc/bash.bashrc).
    if ! shopt -oq posix; then
      if [ -f /usr/share/bash-completion/bash_completion ]; then
        . /usr/share/bash-completion/bash_completion
      elif [ -f /etc/bash_completion ]; then
        . /etc/bash_completion
      fi
    fi
    
    # CUSTOMIZATION
    export PYTHONBREAKPOINT='ipdb.set_trace'
    export EDITOR=emacs
    export PATH=$PATH:~/bin:~/Personal/workspace/bin:
    tty -s && export PS1="\t \u@\h:\w\\$ \[$(tput sgr0)\]"
    umask=0002
    

    ~/.bash_aliases source

    # Package Management
    alias aptls='dpkg-query -L'      # list all files in package
    alias aptop='dpkg -l | grep'     # list local status of all packages matching <string>
    alias ass='apt search'           # Search repositories for <string>
    alias ash='apt show'             # Show package info for package named <string>
    alias asshas='dpkg -S'           # Show all packages in repository that contain a filename that contains <string>
    alias aptapt="apt update && apt upgrade -y && apt autoremove -y && pkcon update"
    
    alias ..='cd ..'
    alias ...='cd ../../'
    alias ....='cd ../../../'
    alias .4='cd ../../../../'
    alias .5='cd ../../../../../'
    
    alias cp='cp --interactive' # ask before clobbering
    
    alias df='duf'
    
    alias diff='delta'
    
    alias duh='dust --depth 1'
    alias duhh='dust --depth 2'
    
    alias e='emacs'
    alias elast='emacs $(!!)'
    alias ew='emacs -nw'
    
    alias gq='geeqie'
    
    alias grep='rg -S'
    alias grepnocomment='rg ^[^#]' 
    
    alias h=history
    alias hig='history | grep '
    
    alias man='man --pager="less -FX"'
    alias less='less --quit-if-one-screen --no-init'
    alias more='less'
    
    alias exa='exa   --all --binary --changed --group --header --long --time-style=long-iso --tree'
    alias l='exa     --level=1 --sort=changed'
    alias ll='exa    --level=2 --sort=changed'
    alias lll='exa   --level=3 --sort=changed'
    alias llll='exa  --tree --level=4 --sort=changed'
    alias lss='exa   --level=1 --sort=size'
    alias lnn='exa   --level=1 --sort=name'
    
    alias ld="l ~/Downloads/"
    
    # if exa isn't installed:
    #alias l=ls\ -alrt\ --block-size="\'1"
    #alias lss=ls\ -alrS\ --block-size="\'1"
    #alias lnn=ls\ -aln\ --block-size="\'1"
    
    alias m='mpv --fs --osd-level=0'
    alias mountt='mount |column -t'
    alias mv='mv --interactive'
    
    # quick local network scan
    alias nmap24='sudo nmap -sn -oX nmap_sn.csv 192.168.1.1/24 | awk '\''/Nmap scan report/ {print "\n" $0; next} 1'\'
    
    # full port scan for one address
    # just use nmap <address>
    
    # Maybe these can be done better with procs but not trivially, and these work already
    alias pf='ps auxf' 
    alias pg='ps aux | grep'
    
    # procs isn't backwards-compatible with ps, so don't use it as such.
    alias prf='procs --tree'
    alias prg='procs --tree | rg'
    
    alias tx='tar xzvf'   # gzip
    alias tj='tar xjvf'   # bzip2
    alias tJ='tar xJvf'   # xz
    
    woo() {
      whois "$1" | grep Creation
    }
    
    calc() {
      echo "scale=2; $1" | bc
    }
    
    compose() {
      grep --ignore-case $1 /usr/share/X11/locale/en_US.UTF-8/Compose 
    }
    
  2. Repeat for root and skel

    sudo cp ~/Dropbox/Basic/new_machine/linux/misc/.bash_aliases ~/Dropbox/Basic/new_machine/linux/misc/.bashrc /root/

    Repeat for skel. sudo cp ~/Dropbox/Basic/new_machine/linux/misc/.bash_aliases ~/Dropbox/Basic/new_machine/linux/misc/.bashrc /etc/skel/