~ashn/setup

8106b8e83bc8a1ddfb8246fec791f17547de613c — ashn 1 year, 11 months ago
Init
A  => bin/git-wipu +6 -0
@@ 1,6 @@
#!/bin/sh
# Update a WIP git branch with an amend and force push.
set -e
git add --all
git commit --amend --no-edit --date="$(date -R)"
git push --force

A  => bin/init-font +2 -0
@@ 1,2 @@
#!/bin/sh
setfont ter-v16n

A  => bin/init-keymap +25 -0
@@ 1,25 @@
#!/bin/sh
# Rebind caps lock to escape within the linux terminal.
# Running `showkey` and then hitting escape and then caps lock shows:
#
#   keycode   1 press
#   keycode   1 release
#   keycode  58 press
#   keycode  58 release
#
# Escape is keycode 1 and caps lock is keycode 58.
#
# Running:
#
#   (dumpkeys | grep keymaps; echo "keycode 58 = Escape")
#
# will produce:
#
#   keymaps 0-127
#   keycode 58 = Escape
#
# which when piped into `loadkeys` will remap the keycode 58 (i.e. caps lock) to
# 'Escape' to get the sweet sweet vim-keyboard escape key.

[ "$(id -u)" != "0" ] && echo 'MUST RUN AS ROOT' && exit 1
(dumpkeys | grep keymaps; echo "keycode 58 = Escape") | loadkeys

A  => bin/init-touchpad +2 -0
@@ 1,2 @@
#!/bin/sh
synclient MaxTapTime=0

A  => bin/init-xmodmap +2 -0
@@ 1,2 @@
#!/bin/sh
xmodmap -e "remove Lock = Caps_Lock" -e "keysym Caps_Lock = Escape"

A  => dotfiles/.bashrc +17 -0
@@ 1,17 @@
# Make Bash conform more closely to the POSIX standard.
set -o posix

# Exit if Bash was not invoked interactively.
[ -z "$PS1" ] && exit 0

# Shell run commands.
[ -f ~/.shrc ] && source ~/.shrc

# Bash completion.
source /etc/bash_completion 2> /dev/null

# Append to the history file, don't overwrite it.
shopt -s histappend
# Check the window size after each command and, if necessary, update the values
# of LINES and COLUMNS.
shopt -s checkwinsize

A  => dotfiles/.env +1 -0
@@ 1,1 @@
PATH="$PATH:$HOME/bin"

A  => dotfiles/.gitconfig +12 -0
@@ 1,12 @@
[user]
	name = ashn
	email = me@ashn.dev
[core]
	editor = vim
	excludesfile = ~/.gitignore
[commit]
	template = ~/.gitmessage
[push]
	default = simple
[credential]
	helper = cache --timeout=86400 ; 24-hours

A  => dotfiles/.gitignore +6 -0
@@ 1,6 @@
# Object Files
*.out
*.o

# Vim Swap Files
*.swp

A  => dotfiles/.gitmessage +18 -0
@@ 1,18 @@
# If this commit is applied it will... (short, 50 characters)

# What change(s) was/were made? How do they address the issue? (long)

# References to tickets/issues/stories (optional)
# Ex: Fixes issue #1234
# Ex: WIP update to #3412

########################################################################
# Remember the 50/72 rule:
# + First line of your commit (the summary) should be a maximum of 50
#   characters. This is for `git shortlog`.
# + All other lines should be a maximum of 72 characters. `git log` adds
#   four spaces of padding, so to center the message on an 80 col
#   terminal, there should be space for four more blank spaces on the
#   right side.
#   (80 - 4 - 4) === 72


A  => dotfiles/.profile +14 -0
@@ 1,14 @@
#!/bin/sh
# .profile : Commands executed by a login using ksh or sh.
export ENV="$HOME/.shrc"

if [ -n "$BASH_VERSION" ]; then
    # include .bashrc if it exists
    if [ -f "$HOME/.bashrc" ]; then
        . "$HOME/.bashrc"
    fi
else
    if [ -f "$HOME/.shrc" ]; then
        . "$HOME/.shrc"
    fi
fi

A  => dotfiles/.shrc +63 -0
@@ 1,63 @@
#!/bin/sh
# .shrc : Common sh-compatible run commands.

[ -f "$HOME/.env" ] && . "$HOME/.env"


## ALIASES
alias ll='ls -alF'
alias ccc='clear;clear;clear'
alias tree='tree -n'

alias shelve='git stash'
alias unshelve='git stash apply'

alias valgrind-mc='valgrind \
    --leak-check=yes \
    --leak-check=full \
    --show-leak-kinds=all \
    --track-origins=yes'
alias gdbt='gdb --tui'


## CUSTOM PS1
git_ps1()
{
    GIT_BRANCH=$(git branch 2> /dev/null | grep '^\* ' | sed -e 's/^\* //g')
    if [ -z "${GIT_BRANCH}" ]; then
        echo ''
        return
    fi

    GIT_STATUS=$(git status 2> /dev/null | tee)
    GIT_REN=$(echo "${GIT_STATUS}" | grep '^.*renamed:')
    GIT_MOD=$(echo "${GIT_STATUS}" | grep '^.*modified:')
    GIT_DEL=$(echo "${GIT_STATUS}" | grep '^.*deleted:')
    GIT_NEW=$(echo "${GIT_STATUS}" | grep '^.*new file:')
    GIT_UNT=$(echo "${GIT_STATUS}" | grep '^Untracked files')

    GIT_STATUS_SUMMARY=''
    if [ -n "${GIT_REN}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}>"
    fi
    if [ -n "${GIT_MOD}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}!"
    fi
    if [ -n "${GIT_DEL}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}x"
    fi
    if [ -n "${GIT_NEW}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}+"
    fi
    if [ -n "${GIT_UNT}" ]; then
        GIT_STATUS_SUMMARY="${GIT_STATUS_SUMMARY}?"
    fi

    if [ ! -z "${GIT_STATUS_SUMMARY}" ]; then
        echo "[${GIT_BRANCH} ${GIT_STATUS_SUMMARY}]"
    else
        echo "[${GIT_BRANCH}]"
    fi
}
export git_ps1
export PS1="\w\[\e[33m\]\`git_ps1\`\[\e[m\]\\$ "

A  => dotfiles/.vimrc +173 -0
@@ 1,173 @@
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" GENERAL CONFIGURATION SETTINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
set nocompatible

color desert
syntax enable

filetype plugin on
filetype indent on

set encoding=utf-8
set spell spelllang=en_us

" Show line numbers by default.
set number
" Turn off wrapping by default.
set nowrap
" Turn off spellchecking by default.
set nospell
" Highlight matching parentheses, braces, and brackets by default.
set showmatch
" Show an 81 column magenta colorcolumn by default.
" Text left of the colorcolum is less than or equal to an 80 column width.
set colorcolumn=81
highlight ColorColumn ctermbg=DarkMagenta guibg=DarkMagenta

" TABS   : >---
" EOL SP : •
set listchars=tab:>-,trail:•
set list

" Set 6 lines to the cursor - when moving vertically using j/k.
set so=6

" Copy indent from the current line when starting a new line.
set autoindent

" Render tabs with 4 space width.
set tabstop=4
" <Tab>, '<', '>', and autoindent use spaces.
set expandtab
" <Tab>, '<', and '>', insert four spaces.
set shiftwidth=4

" Ignore case when searching.
set ignorecase
" Highlight results when searching.
set hlsearch
" Begin searching as characters are entered.
set incsearch

" Change default temp file directories to avoid clutter.
set backupdir=~//
set directory=~//
set undodir=~//

" Lisp style preferences.
autocmd FileType lisp,scheme setlocal tabstop=2 shiftwidth=2 expandtab
" HTML/JavaScript style preferences.
autocmd FileType html,javascript,json setlocal ts=2 sw=2 expandtab
autocmd BufNewFile,BufRead *.ts set syntax=javascript ts=2 sw=2 expandtab

" Linux Kernel style preferences.
function s:SetLinuxKernelStyleConfig()
    setlocal tabstop=8
    setlocal shiftwidth=8
    setlocal noexpandtab
endfunction

""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
""" KEY BINDINGS
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Arrow keys are for wusses.
nnoremap <up>    <nop>
nnoremap <down>  <nop>
nnoremap <left>  <nop>
nnoremap <right> <nop>
inoremap <up>    <nop>
inoremap <down>  <nop>
inoremap <left>  <nop>
inoremap <right> <nop>
vnoremap <up>    <nop>
vnoremap <down>  <nop>
vnoremap <left>  <nop>
vnoremap <right> <nop>

" Remove unused misc commands that I never use.
nnoremap <F> <nop>
nnoremap <M> <nop>
nnoremap <S-L> <nop>
nnoremap <T> <nop>
nnoremap <U> <nop>
nnoremap <C-Y> <nop>
nnoremap <S-J> <nop>
nnoremap <S-k> <nop>
"" <S-L> does not play nice with `set so=<NUMBER>`.
nnoremap <S-L> <nop>
"" <S-M> does not play nice with `set so=<NUMBER>`.
nnoremap <S-M> <nop>
"" <S-Q> is bound to ex mode for historical compatibility.
"" It has only ever been an annoyance.
nnoremap <S-Q> <nop>

" More natural splits.
set splitbelow
set splitright
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

" Tab navigation.
nnoremap <C-n> :tabnext<Return>
nnoremap <C-m> :tabprevious<Return>
nnoremap <C-t> :tabnew<Return>

" Backtab with <shift>+<tab> in insert mode.
inoremap <S-Tab> <C-d>

" Turn off search highlight.
nnoremap <leader><space> :nohlsearch<Return>

" Toggle spellchecking.
function s:ToggleSpellCheck()
    set spell!
    if &spell
        echo "Spellcheck ON"
    else
        echo "Spellcheck OFF"
    endif
endfunction
nnoremap <silent><Leader>sp :call <SID>ToggleSpellCheck()<Return>

" Alternative write-file command.
nnoremap <leader>w :w<Return>

" Insert empty lines without entering insert mode.
nnoremap <leader>o o<Esc>^d$
nnoremap <leader>O O<Esc>^d$

" Explore bindings.
let g:netrw_liststyle=0
nnoremap <leader>ex  :Explore<Return>
nnoremap <leader>tex :Texplore<Return>
nnoremap <leader>vex :Vexplore!<Return>
nnoremap <leader>sex :Sexplore<Return>

" <F1> => Toggle number.
" NOTE: GNOME Terminal will intercept <F1> before vim.
nnoremap <silent><F1> :set number!<Return>

" <F2> => Switch color column between 80 columns, 72 columns, and off.
function s:SwitchColorColumn()
    if &colorcolumn == 81
        set colorcolumn=73
    elseif &colorcolumn == 73
        set colorcolumn=0
    else
        set colorcolumn=81
    endif
endfunction
nnoremap <silent><F2> :call <SID>SwitchColorColumn()<Return>
vnoremap <silent><F2> :call <SID>SwitchColorColumn()<Return>

" <F3> => Toggle between 'insert' and 'insert (paste)' modes.
set pastetoggle=<F3>

" <F4> => Toggle word wrap.
nnoremap <silent><F4> :set wrap!<Return>

" <F5> => Switch to Linux Kernel Editing
nnoremap <silent><F5> :call <SID>SetLinuxKernelStyleConfig()<Return>

A  => setup-apt-packages.sh +74 -0
@@ 1,74 @@
#!/bin/sh
[ "$(id -u)" != "0" ] && echo 'MUST RUN AS ROOT' && exit 1
export DEBIAN_FRONTEND=noninteractive

set -e
set -x

apt-get -y update
apt-get -y upgrade

apt-get -y install apt-utils
apt-get -y install ubuntu-minimal
apt-get -y install build-essential

apt-get -y install linux-tools-common
apt-get -y install linux-tools-generic
apt-get -y install linux-tools-`uname -r`

apt-get -y install network-manager
apt-get -y install wireless-tools

# Dev Tools
apt-get -y install autoconf
apt-get -y install clang
apt-get -y install clang-format
apt-get -y install gcc
apt-get -y install g++
apt-get -y install gdb
apt-get -y install llvm
apt-get -y install musl-tools # musl-gcc
apt-get -y install python
apt-get -y install python3
apt-get -y install racket
apt-get -y install ruby-full
apt-get -y install tcc # Tiny C Compiler.
apt-get -y install valgrind

# Utilities
apt-get -y install ascii
apt-get -y install acpi # Display battery information.
apt-get -y install bash
apt-get -y install bash-completion
apt-get -y install cloc
apt-get -y install curl
apt-get -y install dash
apt-get -y install git
apt-get -y install htop
apt-get -y install iputils-ping # ping
apt-get -y install less
apt-get -y install lzip
apt-get -y install man
apt-get -y install nano
apt-get -y install pandoc
apt-get -y install pass
apt-get -y install powertop # Power consumption and management tool.
apt-get -y install pwgen
apt-get -y install rfkill
apt-get -y install sl
apt-get -y install ssh
apt-get -y install sudo
apt-get -y install tio
apt-get -y install tree
apt-get -y install vim && mkdir -p ~/.vim
apt-get -y install wget
apt-get -y install w3m
apt-get -y install xdotool # X11 CLI keyboard and mouse control.

# GUI
apt-get -y install pavucontrol # PulseAudio Volume Control.
apt-get -y install transmission # BitTorrent Client.
apt-get -y install vlc

# GMP
apt-get -y install libgmp-dev

A  => setup-bin.sh +7 -0
@@ 1,7 @@
#!/bin/sh
set -e
set -x

mkdir -p ~/bin
chmod 755 ~/bin
cp bin/* ~/bin/

A  => setup-dotfiles.sh +12 -0
@@ 1,12 @@
#!/bin/sh
set -e
set -x

cp dotfiles/.bashrc ~/
cp dotfiles/.env ~/
cp dotfiles/.gitconfig ~/
cp dotfiles/.gitignore ~/
cp dotfiles/.gitmessage ~/
cp dotfiles/.profile ~/
cp dotfiles/.shrc ~/
cp dotfiles/.vimrc ~/

A  => setup.adoc +16 -0
@@ 1,16 @@
Setup
=====

Run `setup-apt-packages.sh`.
Run `setup-bin.sh`.
Run `setup-dotfiles.sh`.

Goto Settings Panel -> Input -> Key Bindings and add the following key bindings:
. CTRL+ALT+T ==> Command w/ action params:
  .. `terminology --maximized --visual-bell=false --cursor-blink=false`
. CTRL+ALT+SHIFT+Left ==> To Previous Desktop
. CTRL+ALT+SHIFT+Right ==> To Next Desktop

In `terminology` right click and edit settings by clearing the `temporary`
check box and then editing as desired.
Under background make sure the image is `none` and shine is at zero.