dot

packages and services management
Log | Files | Refs | README

commit 322f772e6ffc0062aa1bbd7355a95ac3f957637a
parent 16c1add1a0bc9d5162a43b32f3f41187c8343eee
Author: josuah <mail@josuah.net>
Date:   Tue,  4 Oct 2016 14:42:49 -0400

Fixed irc script and cleanup

Diffstat:
Mbin/complete | 10+++++-----
Mbin/irc | 76++++++++++++++++++++++++++++++++++++++++++++++------------------------------
Mbin/src | 6+++---
Dex-vi/.exrc | 22----------------------
Dex-vi/build.sh | 10----------
Dfzy/build.sh | 3---
Dfzy/config.h | 10----------
Dlchat/build.sh | 3---
Mlua/build.sh | 5++---
Dratox/build.sh | 3---
Mshell/.pam_environment | 2+-
Mshell/.profile | 17++++++++++-------
Dtoxcore/build.sh | 3---
Mvim/.vim/vimrc | 7+++----
14 files changed, 70 insertions(+), 107 deletions(-)

diff --git a/bin/complete b/bin/complete @@ -28,24 +28,24 @@ do case "$1" in -w | -l ) ACTION="$1" ;; -* ) printf '%s\n' "$help" && exit 0 ;; - * ) FILE="$1" ;; + * ) file="$1" ;; esac shift done -PREFIX="$(tee)" +prefix="$(tee)" case "$ACTION" in -w ) - sed 's/[[:space:]]/\n/g' "$FILE" | sort -u | while read word - do [ -z "${word##$PREFIX*}" ] && printf '%s\n' "$word" + sed 's/[[:space:]]/\n/g' "$file" | sort -u | while read word + do [ -z "${word##$prefix*}" ] && printf '%s\n' "$word" done | fzf | { IFS="$NL" read -r word printf '%s\n' "$word" } ;; -l ) - fzf -q "$PREFIX" < "$FILE" + fzf -q "$prefix" < "$file" ;; esac diff --git a/bin/irc b/bin/irc @@ -42,15 +42,15 @@ connect() mkdir -p "$srv" [ -p "$srv/IN" ] || mkfifo "$srv/IN" + printf "$user" > "$srv/NICK" + # Connect to irc server, send command from the pipe, parse the messages. - tail -f "$srv/IN" | nc "$srv" 6667 | while IFS= read -r msg + tail -f "$srv/IN" | nc "$srv" 6667 | tee -a ~/log | while IFS= read -r msg do parse_message "$srv" done & write "$srv" "NICK $user" write "$srv" "USER $user +i * :$FULLNAME" - - printf "$user" > "$srv/NICK" } # @@ -141,8 +141,10 @@ parse_message() local prefix='' nick='' cmd='' trail='' sep='' local params='' middle='' chan='' user="$(tail "$srv/NICK")" - # Prefix + # Remove the useless '\r' character msg="${msg#$CR}" msg="${msg%$CR}" + + # Prefix (and nick) if [ -z "${msg##:*}" ] then prefix="${msg%% *}" prefix="${prefix#:}" @@ -154,42 +156,50 @@ parse_message() cmd="${msg%% *}" msg="${msg#* }" # Parameters - [ -z "${msg##* *}" ] && params="${msg# *}" - case "$msg" in - :* ) trail="${params#:}" ;; - *:* ) trail="${params#*:}" middle="${params%%:*}" ;; - * | '' ) middle="$params" ;; + params="${msg# *}" + case "$params" in + :* ) + trail="${params#:}" + ;; + *:* ) + trail="${params#*:}" middle="${params%%:*}" + ;; + * ) + middle="$params" + ;; esac # Channel and extra command action case "$cmd" in - JOIN ) chan="$trail" ;; - PART ) chan="$middle" ;; + JOIN | PART ) + chan="$middle" + ;; PRIVMSG ) - if [ "$middle" = "$user" ] - then chan="$nick" - else chan="$middle" - fi + [ "$middle" = "$user" ] && chan="$nick" || chan="$middle" ;; - NICK ) chan="SERVER" - if [ "$nick" = "$user" ] - then printf '%s\n' "$trail" > "$srv/NICK" - fi + NICK ) + chan=SERVER + [ "$nick" = "$user" ] && printf '%s\n' "$trail" > "$srv/NICK" ;; QUIT | NOTICE | [0-9][0-9][0-9] | * | '' ) chan=SERVER ;; esac + printf 'cmd: %-10s middle: %-10s chan: %-10s %s\n\n' \ + "$cmd" "$middle" "$chan" "$params" >> ~/log + # Execute action case "$cmd" in PING ) write "$srv" "PONG $trail" ;; - QUIT | NICK | JOIN ) - find "$srv" -name '#*' -o -name "SERVER" | while read chan - do print_msg "$nick" "$trail" "$cmd" "$srv" "${chan#$srv}" \ - >> "$chan" + QUIT | NICK ) + grep -l -r "$nick" | while read chan + do + chan="${chan#$srv/}" + print_msg "$nick" "$trail" "$cmd" "$srv" "$chan" \ + >> "$srv/$chan" done ;; *) @@ -199,7 +209,7 @@ parse_message() # Bot actions case "$trail" in - 'VERSION' ) write "$srv" "PRIVMSG $nick :VERSION nc + sh" ;; + 'VERSION'* ) write "$srv" "PRIVMSG $nick :VERSION nc + sh" ;; esac } @@ -212,10 +222,14 @@ print_msg() local user="$(tail "$srv/NICK")" last_cmd last_nick case "$cmd" in - ( QUIT ) cmd='<' ;; ( JOIN ) cmd='>' ;; - ( PRIVMSG ) cmd='|' ;; ( NOTICE ) cmd='!' ;; - ( PART ) cmd='~' ;; ( ERROR ) cmd='X' ;; - ( MODE ) cmd='+' ;; ( NICK ) cmd='=' ;; + QUIT ) cmd='<' ;; + JOIN ) cmd='>' ;; + PRIVMSG ) cmd='|' ;; + NOTICE ) cmd='!' ;; + PART ) cmd='~' ;; + ERROR ) cmd='X' ;; + MODE ) cmd='+' ;; + NICK ) cmd='=' ;; esac # Single line separator at the right place. @@ -227,7 +241,9 @@ print_msg() last_cmd="$(tail -n 1 "$srv/$chan" | cut -c $(($NICK_LEN + 2))-)" last_cmd="${last_cmd%% *}" - if [ "$cmd" = '|' ] && [ "$last_nick" != "$nick" ] || [ "$cmd" != "$last_cmd" ] + if [ "$cmd" = '|' ] \ + && [ "$last_nick" != "$nick" ] \ + || [ "$cmd" != "$last_cmd" ] then printf "%${NICK_LEN}s |\n" fi @@ -258,7 +274,7 @@ case "$1" in ;; -o ) IFS="$NL" - less -R $(find . -mindepth 2 -type f) + less $(find . -mindepth 2 -type f ! -name NICK) unset IFS ;; * ) diff --git a/bin/src b/bin/src @@ -6,9 +6,9 @@ #=============================================================================== # Install sources using crux-like package declaration. -PROGRAMS="${PROGRAMS-$HOME/Programs}" -PREFIX="$HOME/.local" -CONFIG="${CONFIG-$HOME/Config}" +PROGRAMS="${PROGRAMS:-$HOME/Programs}" +PREFIX="${LOCAL:-$HOME/.local}" +CONFIG="${CONFIG:-$HOME/Config}" # FUNCTIONS diff --git a/ex-vi/.exrc b/ex-vi/.exrc @@ -1,22 +0,0 @@ -" ___ __ __ _____ ____ -" .'__ \ \ \' // ____\/ ___\ -" / ____/ ,' ,'/ / / /__ -" \___\ /_,\_\ \/ \____\ -"=============================================================================== -" -" -" OPTIONS -"------------------------------------------------------------------------------- -" -set shiftwidth=8 tabstop=8 hardtabs=8 -set autoindent autoprint -set beautify -set modelines -set showmode showmatch number -set errorbells flash -" -" -" KEYBINDINGS -"------------------------------------------------------------------------------- -" -map g 1G diff --git a/ex-vi/build.sh b/ex-vi/build.sh @@ -1,10 +0,0 @@ -# Modern implementation of Traditionnal Ex and Vi - -tar=http://prdownloads.sourceforge.net/ex-vi/ex-050325.tar.bz2 - -build() -{ - sed -ri 's/^(#define *TUBECOLS *) [0-9]+/\1 400/' config.h - make - cp ex ../bin/ex-vi -} diff --git a/fzy/build.sh b/fzy/build.sh @@ -1,3 +0,0 @@ -# Fuzzy finder that rocks - -tar=http://github.com/jhawthorn/fzy/archive/master.tar.gz diff --git a/fzy/config.h b/fzy/config.h @@ -1,10 +0,0 @@ -#define TTY_COLOR_HIGHLIGHT TTY_COLOR_GREEN - -#define SCORE_GAP_LEADING -0.005 -#define SCORE_GAP_TRAILING -0.005 -#define SCORE_GAP_INNER -0.01 -#define SCORE_MATCH_CONSECUTIVE 1.0 -#define SCORE_MATCH_SLASH 0.9 -#define SCORE_MATCH_WORD 0.8 -#define SCORE_MATCH_CAPITAL 0.7 -#define SCORE_MATCH_DOT 0.6 diff --git a/lchat/build.sh b/lchat/build.sh @@ -1,3 +0,0 @@ -# Interface to binoc chat clients - -tar=http://github.com/younix/lchat/archive/master.tar.gz diff --git a/lua/build.sh b/lua/build.sh @@ -4,5 +4,5 @@ tar='http://www.lua.org/ftp/lua-5.3.2.tar.gz' build() { - make INSTALL_TOP="$PREFIX" "$(uname | tr [A-Z] [a-z])" test install -}- \ No newline at end of file + make INSTALL_TOP="$PREFIX" "$(uname | tr [A-Z] [a-z])" install +} diff --git a/ratox/build.sh b/ratox/build.sh @@ -1,3 +0,0 @@ -# FIFO-based tox chat client - -tar=http://dl.2f30.org/releases/ratox-0.2.1.tar.gz diff --git a/shell/.pam_environment b/shell/.pam_environment @@ -25,7 +25,7 @@ FILTER DEFAULT=peax CONFIG DEFAULT=@{HOME}/Config MAIL DEFAULT=@{HOME}/Mail/INBOX -PREFIX DEFAULT=@{HOME}/.local +LOCAL DEFAULT=@{HOME}/.local ENV DEFAULT=@{HOME}/.profile MANPATH DEFAULT=${MANPATH}:${PREFIX}/share/man:${PREFIX}/man LD_LIBRARY_PATH DEFAULT=${PREFIX}/lib diff --git a/shell/.profile b/shell/.profile @@ -18,7 +18,7 @@ export PROFILE_LOADED=1 export PS1='$(ps1)' export PS2='| ' -export PATH="$CONFIG/bin:$PREFIX/bin:$PATH" +export PATH="$CONFIG/bin:$LOCAL/bin:$PATH" solarized_light="\ \033]P0ffddbb \033]P1d0154b \033]P2779900 \033]P3ffa700\ @@ -58,7 +58,6 @@ alias la='l -A' alias lla='l -Alh' alias v='$VISUAL' alias p='$PAGER' -alias t='tmux attach || tmux' alias f='find . -type f ! -path "*/.git/*" | fzf' alias d='find . -type d ! -path "*/.git/*" | fzf' alias c='cd "$(find . -maxdepth 4 -mindepth 1 -type d | fzf)"' @@ -267,8 +266,12 @@ rotate() # STARTUP #------------------------------------------------------------------------------- -#if [ "$TERM" = 'linux' ] -#then -# printf "$coal" # Theme -# printf '\033[?6;c' # Cursor style -#fi +# TTY setup +if [ "$TERM" = 'linux' ] +then + printf "$coal" # Theme + printf '\033[?6;c' # Cursor style +fi + +# Start tmux right away +command -v tmux &> /dev/null && [ -z "$TMUX" ] && tmux attach diff --git a/toxcore/build.sh b/toxcore/build.sh @@ -1,3 +0,0 @@ -# Tox chat protocol core libraries - -tar=http://github.com/irungentoo/toxcore/archive/master.tar.gz diff --git a/vim/.vim/vimrc b/vim/.vim/vimrc @@ -14,11 +14,10 @@ syntax enable | filetype plugin on | set nocompatible set omnifunc=syntaxcomplete#Complete " Completion set autoindent copyindent " Indentation -set laststatus=1 showcmd " Status -set ruler "rulerformat=%=%P +set laststatus=2 showcmd ruler showmode " Status set smartcase ignorecase showmatch incsearch " Searching set list listchars=tab::\ ,trail:.,nbsp:.,extends:>,precedes:< " Listchars -set fillchars=stl:─,stlnc:─,vert:: " Fillchars +set fillchars=stl:─,stlnc:─,vert:│,fold:─,diff:─ " Fillchars set number numberwidth=1 cursorline nowrap " Interface set scrolloff=3 " Scroll set backupdir=~/.cache/vim// directory=~/.cache/vim// undodir=~/.cache/vim// @@ -45,7 +44,7 @@ nmap <Leader><Leader> : \ ec ' <m> make '"<'>"'marks' \| \ <CR>: nmap <Leader>w :w<CR> -nmap <Leader>s :set <C-d> +nmap <Leader>s :set nmap <Leader>h :help nmap <Leader>b :pwd \| echo '' \| ls \| echo ''<CR>:b nmap <Leader>T :pwd \| echo '' \| tabs \| echo ''<CR>:tab