dot

packages and services management
Log | Files | Refs | README

commit b603af2c83c2a69c55391e67ce242188f0167986
parent e9954ea21403b03862abd155293635158f341125
Author: josuah <mail@josuah.net>
Date:   Tue, 24 Jan 2017 14:17:16 +0100

Updated the README script.

Diffstat:
A.local/bin/iii | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
M.profile | 2+-
DREADME | 70----------------------------------------------------------------------
AREADME.sh | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 190 insertions(+), 71 deletions(-)

diff --git a/.local/bin/iii b/.local/bin/iii @@ -0,0 +1,133 @@ +# wrapper script for ii irc client http://tools.suckless.org/ii + + +II_DIR="$HOME/.cache/irc" + + +# +# Read one character from /dev/tty in raw mode. +# +get_char() +{ + stty -echo raw + dd count=1 2> /dev/null + stty sane +} + + +# +# Manage characters typed by user. +# +input() +{ + printf '' > input + + print_prompt + + while key="$(get_char)" + do + case "$key" in + ( [[:print:]] ) + printf %s "$key" >> input + ;; + + ( "$(printf '\020')" | "$(printf '\016')" ) # Ctrl-P Ctrl-N + ;; + + ( "$(printf '\033')" | "$(printf '\003')" ) # Escape Ctrl-C + exit 0 + ;; + + ( "$(printf '\015')" ) # Ctrl-M Enter + IFS='' read -r channel < channel + sed 's/$/\n/' input > "$channel/in" + printf '' > input + ;; + + ( "$(printf '\025')" ) # Ctrl-U + printf '' > input + ;; + + ( "$(printf '\027')" ) # Ctrl-W + sed -i 's/[^ \t]* *$//' input + ;; + + ( "$(printf '\010')" | "$(printf '\177')" ) # Ctrl-H Backspace + sed -i 's/.$//' input + ;; + + ( "$(printf '\014')" ) # Ctrl-L + IFS='' read -r channel < channel + less "$channel/out" + print_screen + ;; + esac + + print_prompt + done +} + + +# +# Print a prompt with the current input +# +print_prompt() +{ + size="$(stty -F /dev/tty size)" + + IFS='' read -r channel < channel + IFS='' read -r input < input + + width="$(((${#input} + ${#channel} + 4) - ${size#* }))" + + if [ "$width" -gt 0 ] + then + input="$(printf %s "$input" | cut -c "$width"- | tr -d '\n')" + fi + + printf '\r\033[K%s> %s' "$channel" "$input" +} + + +# +# Update the buffer lines and prompt +# +print_screen() +{ + size="$(stty -F /dev/tty size)" + + stty sane + + printf '\033[H\033[J' + [ -f out ] && tail -n "${size#* }" out + print_prompt + + stty raw +} + + +# +# Print lines after formatting them and update the prompt. +# +print_lines() +{ + while IFS='' read -r line + do + printf '\a\r\033[K%s\n' "$line" + print_prompt + done +} + + +main() +{ + touch channel in + + trap 'print_screen' SIGWINCH + trap 'stty sane; stop' EXIT + + input +} + + +main "$@" diff --git a/.profile b/.profile @@ -50,7 +50,7 @@ export PS3='│ ' # coreutils alias p='page' alias l='list' -alias la='ls -alhp --color' +alias la='ls -Alhp --color' alias cl='printf "\033[H\033[2J"' alias bh='page busybox --help' alias grep='page grep' diff --git a/README b/README @@ -1,70 +0,0 @@ -: '_ _ - / _ __ /_ . _ - \_ (_) | | | | (_| - _| -________________________________________________________________________________ - - Configuration files for UNIX distros, shell agnostic. - - I have no C++ in this repo and much more shell scripts. GitHub is - not detecting all source types accurately for C headers and shell - script without shebangs. - - This file is the installer script. You can run it. - - -Scripts (/bin) -________________________________________________________________________________ - - Scripts are in ./.local/bin. I wrote them to be compatible with - any shell, and but for the shebang (android breaks everything). - - fig1, fig2 - Single-file figlet implementation, with built-in fonts. - - git-prompt - Simple awk script to display git information in the prompt, - - blawk, drawk - Represent an image with text characters either braille or - quadrants. - ' - -cd "${0%/*}" || exit 1 -find . -type d ! -path './.git*' -path './.*' -exec mkdir -p ~/{} \; -find . -type f ! -path './.git*' -path './.*' -exec ln -sf "$PWD/{}" ~/{} \; -find -L ~ -type l -exec rm {} \; - -mkdir -p ~/src "$MAIL/cur" "$MAIL/new" "$MAIL/tmp" - -case "$1" in -g | git ) - cd ~/src || exit - git clone ssh://repo.or.cz/iomenu.git - git clone http://github.com/josuah/iode & - git clone http://github.com/josuah/josuah.github.io & - git clone http://github.com/josuah/cgr & - git clone http://github.com/josuah/build & - git clone http://github.com/josuah/notes & - git clone http://github.com/josuah/fungus-vs-pathogen & - git clone http://github.com/josuah/miniwi & - git clone http://github.com/josuah/drawille & - wait - ;; - -m | mail ) - printf '<address@mail.net> <imap.host.net> <password>:' - read -r a h p - printf 'machine %s\nlogin %s\npassword "%s"' "$h" "$a" "$p" > ~/.netrc - printf '\033[A\r\033[K' - chmod 400 "$HOME/.netrc" - ;; - -b | build ) - tmp="$(mktemp -d)" && cd "$tmp" || exit 1 - wget -O - http://github.com/josuah/build/archive/master.tar.gz | - tar zxf - && cd build-master || exit 1 - make PREFIX="$HOME/.local" install - cd && rm -r "$tmp" - ;; -esac diff --git a/README.sh b/README.sh @@ -0,0 +1,56 @@ +case "$1" in + + +l | link ) # link the dotfiles in this directory + + cd "${0%/*}" || exit 1 + + find . -path './.*' ! -path './.git*' | while IFS='' read -r path + do + [ -d "$path" ] && mkdir -p ~"${path#.}" + [ -f "$path" ] && ln -sf "$path" ~"${path#.}" + done + + find -L ~ -type l -exec rm {} \; + ;; + + +g | git ) # my other projects + + mkdir -p ~/src && cd ~/src || exit + + git clone ssh://repo.or.cz/iomenu.git + git clone http://github.com/josuah/iode & + git clone http://github.com/josuah/josuah.github.io & + git clone http://github.com/josuah/cgr & + git clone http://github.com/josuah/build & + git clone http://github.com/josuah/notes & + git clone http://github.com/josuah/fungus-vs-pathogen & + git clone http://github.com/josuah/miniwi & + git clone http://github.com/josuah/drawille & + + wait + ;; + + +b | build ) # package manager + + wget -O - http://github.com/josuah/build/archive/master.tar.gz | + tar zxf - && cd build-master || exit + make PREFIX=~/.local install + cd .. && rm -rf build-master + ;; + + +m | mail ) # setup mail credentials + + mkdir -p "$MAIL/cur" "$MAIL/new" "$MAIL/tmp" + + printf '<address@mail.net> <imap.host.net> <password>:' + read -r a h p + printf '\033[A\033[2K' + printf 'machine %s\nlogin %s\npassword "%s"' "$h" "$a" "$p" > ~/.netrc + chmod 400 ~/.netrc + ;; + +esac