Update some user configs

This commit is contained in:
natemaia 2018-10-23 21:11:58 -07:00
parent 15fde92d60
commit dd505e5509
4 changed files with 194 additions and 163 deletions

View File

@ -277,14 +277,14 @@
# Otherwise the "#" and following would be interpreted as a comment. # Otherwise the "#" and following would be interpreted as a comment.
background = "#1c2023" background = "#1c2023"
foreground = "#a4a4a4" foreground = "#a4a4a4"
timeout = 10 timeout = 5
# Icon for notifications with low urgency, uncomment to enable # Icon for notifications with low urgency, uncomment to enable
#icon = /path/to/icon #icon = /path/to/icon
[urgency_normal] [urgency_normal]
background = "#1c2023" background = "#1c2023"
foreground = "#a4a4a4" foreground = "#a4a4a4"
timeout = 10 timeout = 5
# Icon for notifications with normal urgency, uncomment to enable # Icon for notifications with normal urgency, uncomment to enable
#icon = /path/to/icon #icon = /path/to/icon
@ -292,7 +292,7 @@
background = "#1c2023" background = "#1c2023"
foreground = "#a4a4a4" foreground = "#a4a4a4"
frame_color = "#a4a4a4" frame_color = "#a4a4a4"
timeout = 0 timeout = 10
# Icon for notifications with critical urgency, uncomment to enable # Icon for notifications with critical urgency, uncomment to enable
#icon = /path/to/icon #icon = /path/to/icon

View File

@ -16,16 +16,8 @@ endif
let g:colors_name = 'jinx' let g:colors_name = 'jinx'
if exists('g:jinx_theme_toggle_key') && g:jinx_theme_toggle_key !=# ''
let s:t_key = g:jinx_theme_toggle_key
else
let s:t_key = ''
if maparg('T', 'n') ==# ''
let s:t_key = 'T'
endif
endif
" Colors {{{2 " Colors {{{1
" empty color dictionary " empty color dictionary
let s:jinx = {} let s:jinx = {}
@ -83,25 +75,8 @@ else
let s:jinx.orange = ['#FF9157', 208] let s:jinx.orange = ['#FF9157', 208]
endif endif
" Functions {{{2
if !exists('g:jinx_theme_toggle_loaded') && s:t_key !=# '' function! <SID>HighLight(GRP, FG, BG, ATT) abort " {{{1
let g:jinx_theme_toggle_loaded = 1
function! Toggle_Theme() abort
if exists('g:jinx_colors') && g:jinx_colors =~? 'day'
let g:jinx_colors = 'night'
else
let g:jinx_colors = 'day'
endif
unlet g:colors_name
colorscheme jinx
let g:colors_name = 'jinx'
endfunction
execute 'nnoremap <silent> '.s:t_key.' :call Toggle_Theme()<CR>'
endif
function! <SID>HighLight(GRP, FG, BG, ATT) abort
if a:FG !=# '' if a:FG !=# ''
let l:fg_col = get(s:jinx, a:FG) let l:fg_col = get(s:jinx, a:FG)
let l:fg_true = l:fg_col[0] let l:fg_true = l:fg_col[0]
@ -128,14 +103,14 @@ call <SID>HighLight('Title', 'commnt', 'bgr', 'bold')
call <SID>HighLight('Visual', '', 'select', '') call <SID>HighLight('Visual', '', 'select', '')
call <SID>HighLight('SignColumn', '', 'line', '') call <SID>HighLight('SignColumn', '', 'line', '')
call <SID>HighLight('CursorLine', '', 'line', 'none') call <SID>HighLight('CursorLine', '', 'line', 'none')
call <SID>HighLight('CursorColumn', '', 'line', '') call <SID>HighLight('CursorColumn', '', 'line', '')
call <SID>HighLight('CursorLineNr', 'cyan', 'line', '') call <SID>HighLight('CursorLineNr', 'cyan', 'line', '')
call <SID>HighLight('LineNr', 'commnt', 'line', '') call <SID>HighLight('LineNr', 'commnt', 'line', '')
call <SID>HighLight('ColorColumn', 'fgr', 'red', '') call <SID>HighLight('ColorColumn', 'fgr', 'red', '')
call <SID>HighLight('Error', 'red', 'bgr', '') call <SID>HighLight('Error', 'red', 'bgr', '')
call <SID>HighLight('ErrorMsg', 'red', 'bgr', '') call <SID>HighLight('ErrorMsg', 'red', 'bgr', '')
call <SID>HighLight('WarningMsg', 'red', 'bgr', '') call <SID>HighLight('WarningMsg', 'red', 'bgr', '')
call <SID>HighLight('MatchParen', 'blue', 'line', 'underline') call <SID>HighLight('MatchParen', 'blue', 'bgr', 'bold')
call <SID>HighLight('ModeMsg', 'cyan', 'bgr', '') call <SID>HighLight('ModeMsg', 'cyan', 'bgr', '')
call <SID>HighLight('MoreMsg', 'cyan', 'bgr', '') call <SID>HighLight('MoreMsg', 'cyan', 'bgr', '')
call <SID>HighLight('Directory', 'blue', 'bgr', '') call <SID>HighLight('Directory', 'blue', 'bgr', '')
@ -160,29 +135,27 @@ call <SID>HighLight('PmenuThumb', 'menu_fgr', 'menu_bgr', '')
call <SID>HighLight('StatusLine', 'menu_bgr', 'menu_fgr', '') call <SID>HighLight('StatusLine', 'menu_bgr', 'menu_fgr', '')
call <SID>HighLight('StatusLineNC', 'menu_fgr', 'menu_bgr', '') call <SID>HighLight('StatusLineNC', 'menu_fgr', 'menu_bgr', '')
" Spell {{{2 if has('spell') " {{{2
if has('spell')
call <SID>HighLight('SpellBad', '', '', 'undercurl') call <SID>HighLight('SpellBad', '', '', 'undercurl')
call <SID>HighLight('SpellLocal', '', '', 'undercurl') call <SID>HighLight('SpellLocal', '', '', 'undercurl')
call <SID>HighLight('SpellRare', '', '', 'undercurl') call <SID>HighLight('SpellRare', '', '', 'undercurl')
endif endif
" CtrlP {{{2 if exists('g:loaded_ctrlp') " {{{2
call <SID>HighLight('CtrlPNoEntries', 'red', '', 'bold')
call <SID>HighLight('CtrlPMatch', 'blue', '', 'bold')
call <SID>HighLight('CtrlPLinePre', 'blue', 'menu_bgr', 'none')
call <SID>HighLight('CtrlPPrtBase', 'blue', '', 'none')
call <SID>HighLight('CtrlPPrtCursor', 'menu_fgr', 'menu_bgr', 'bold')
call <SID>HighLight('CtrlPMode1', 'menu_fgr', 'menu_bgr', 'bold')
call <SID>HighLight('CtrlPMode2', 'menu_fgr', 'menu_bgr', 'bold')
call <SID>HighLight('CtrlPStats', 'menu_fgr', 'menu_bgr', 'bold')
endif
call <SID>HighLight('CtrlPNoEntries', 'red', '', 'bold') if exists('g:loaded_ale') " {{{2
call <SID>HighLight('CtrlPMatch', 'blue', '', 'bold') call <SID>HighLight('ALEErrorSign', 'red', 'line', 'bold')
call <SID>HighLight('CtrlPLinePre', 'blue', 'menu_bgr', 'none') call <SID>HighLight('ALEWarningSign', 'orange', 'line', 'bold')
call <SID>HighLight('CtrlPPrtBase', 'blue', '', 'none') endif
call <SID>HighLight('CtrlPPrtCursor', 'menu_fgr', 'menu_bgr', 'bold')
call <SID>HighLight('CtrlPMode1', 'menu_fgr', 'menu_bgr', 'bold')
call <SID>HighLight('CtrlPMode2', 'menu_fgr', 'menu_bgr', 'bold')
call <SID>HighLight('CtrlPStats', 'menu_fgr', 'menu_bgr', 'bold')
" ALE {{{2
call <SID>HighLight('ALEErrorSign', 'red', 'line', 'bold')
call <SID>HighLight('ALEWarningSign', 'orange', 'line', 'bold')
" Generic {{{2 " Generic {{{2
@ -460,7 +433,7 @@ call <SID>HighLight('DiffText', 'line', 'blue', 'bold')
" Cleanup {{{2 " Cleanup {{{2
" Remove the highlight function as it's no longer needed. " Remove the highlight function as it's no longer needed.
" Will cause problems toggling the theme if not deleted. " Will cause problems reloading the theme if not deleted.
delfunction <SID>HighLight delfunction <SID>HighLight
" vim:fdm=marker:et:sts=4:sw=4 " vim:fdm=marker:et:sts=4:sw=4

View File

@ -1,5 +1,7 @@
# .zprofile # ~/.zprofile
# sourced by zsh when used as a login shell # sourced by zsh when used as a login shell
# automatically run startx when logging in on tty1 # automatically run startx when logging in on tty1
[[ -z $DISPLAY && $XDG_VTNR -eq 1 ]] && exec startx -- vt1 &>/dev/null if [[ ! $DISPLAY && $TERM == 'linux' && $XDG_VTNR -eq 1 ]]; then
exec startx -- vt1 -keeptty > ~/.local/share/xorg/xorg.log
fi

View File

@ -1,134 +1,190 @@
#!/bin/bash #!/bin/bash
# Simple tool to update and install AUR packages for Arch Linux # Simple tool to update and install AUR packages for Arch Linux
#
# Written by Nathaniel Maia, September 2018 # Written by Nathaniel Maia, September 2018
#
# This software is provided free of charge and WITHOUT warranty # This software is provided free of charge and WITHOUT warranty
declare -g PKGS=() # array of AUR packages declare -g NOVIEW="" # disable viewing the PKGBUILD
declare -g NOVIEW=0 # view the PKGBUILD of each AUR package declare -g NOCONF="" # disable extra confirmations
declare -g NOCONF=0 # no confirmation after viewing the PKGBUILD declare -i CACHE=0 # keep cached package downloads
declare -g BDIR="$HOME/.cache/aur_builds" # AUR build directory readonly BUILD_DIR="$HOME/.cache/aur_builds" # AUR build directory
declare -g AUR="https://aur.archlinux.org" # AUR address readonly AUR_ADDR="https://aur.archlinux.org" # AUR web address
readonly PKG_ADDR="$AUR_ADDR/packages" # AUR package address
readonly SCRIPT="$(readlink -f $0)" ## ----------------------------------------------------------------- ##
readonly BASENAME="${0#*/}"
usage() { readonly SCRIPT="$(readlink -f "$0")" # real path to this file
declare -a AUR_PKGS=() # array of AUR packages
declare -a PAC_PKGS=() # array of official packages
usage() { # show the standard UNIX style help message.. usage: usage
cat <<- EOF cat <<- EOF
B.A.P.H - Basic AUR Package Helper baph - Basic AUR Package Helper, a simple script to install and update packages
A simple and short script that allows installing and updating packages usage: baph <operation> [package(s)] [options]
USAGE: $NAME [OPTIONS] [PACKAGE] operations:
baph {-h --help}
baph {-u --update} [package(s)] [options]
baph {-i --install} <package(s)> [options]
options:
--noview Skip viewing the PKGBUILD for AUR packages and dependencies
--noconfirm Skip most confirmations when building also passed to pacman
OPTIONS:
--help,-h Display this message
--update,-u Update all AUR packages on the system
--noview,-n Skip viewing the PKGBUILD for AUR packages
--noconfirm Skip confirmation after viewing the PKGBUILD
EOF EOF
}
#-- Utility functions --#
msg() { printf "$1\e[0m \e[1m$2\e[0m\n"; }
die() { printf "\e[1m\e[31merror:\e[0m $1\n"; exit ${2:-1}; }
comp() { # compare AUR package versions, returns 0 or 1.. usage: comp "package" "current version"
NEW="$(curl --silent "$PKG_ADDR/$1" | awk '/Details:/ {sub(/<\/h.?>/, ""); print $4}')"
[[ -n $NEW && "$2" == "$NEW" ]] && return 0 || return 1
}
yesno() { # only shown when not using --noconfirm, returns 0 or 1.. usage: yesno "question"
if [[ $NOCONF ]]; then
printf "\n\e[34m::\e[0m \e[1m$1? [Y/n]\e[0m "; read -r conf
[[ $conf =~ [nN] ]] && return 1 # return non zero when confirm n/N
fi
return 0
}
#-- Update functions --#
prepupdate() { # prep for package update.. usage: prepupdate
(( ${#AUR_PKGS[@]} == 0 )) || update # exits here if passed packages to update
sudo pacman -Syyu $NOCONF || exit 1
AUR_PKGS=($(pacman -Qqm 2>/dev/null))
(( ${#AUR_PKGS[@]} == 0 )) && msg '\e[34m::' "No AUR packages installed.." || update
}
update() { # check update for each package in AUR_PKGS=().. usage: update
local cur
local up=()
msg '\e[34m::' "Synchronizing AUR package versions..."
for i in "${AUR_PKGS[@]}"; do
ver="$(pacman -Qs "^$i$" 2>/dev/null | awk 'NR==1 {print $2}')"
if [[ $ver ]]; then
comp "$i" "$ver" && printf "$i-$ver --> up to date\n" || up+=("$i")
else
msg '\e[33m::' "$i is not installed.. skipping"
fi
done
msg '\e[34m::' "Starting AUR package upgrade..."
if (( ${#up[@]} > 0 )); then
printf "\n\e[1mPackages (${#up[@]})\e[0m %s\n\n" "${up[@]}"
for i in "${up[@]}"; do
getpkg "$i"
done
else
printf " there is nothing to do\n"
fi
exit 0 exit 0
} }
die() { #-- Install functions --#
echo "$1" && exit ${2:-0}
}
comp() { prepinstall() { # loop package arrays if set and install each.. usage: prepinstall
old="$(pacman -Qs "^$1$" | awk 'NR==1 {print $2}')" (( ${#PAC_PKGS[@]} == 0 && ${#AUR_PKGS[@]} == 0 )) && die "no targets specified" 2
new="$(curl --silent $AUR/packages/$1 | awk '/Details:/ {sub(/<\/h.?>/, ""); print $4}')" (( ${#PAC_PKGS[@]} > 0 )) && sudo pacman -S ${PAC_PKGS[*]} $NOCONF
[[ "$old" == "$new" ]] && return 0 || return 1 for pkg in "${AUR_PKGS[@]}"; do
} response="$(curl --silent --head "$PKG_ADDR/$pkg" | awk 'NR==1 {print $2}')"
(( response == 200 )) || die "$response response from $PKG_ADDR/$pkg"
buildp() { getpkg "$pkg" || msg '\e[33m::' "Exiting $pkg build early"
local p="$1"
# evaluating the PKGBUILD could be dangerous but is short
# the user has either viewed and confirmed it or doesn't care and passed --noconfirm
eval "$(cat "$BDIR/$p/PKGBUILD")"
for d in ${depends[@]}; do
pacman -Ssq "^$d$" >/dev/null 2>&1 || $SCRIPT --noview --noconfirm "$d"
done done
}
getpkg() { # install an AUR package.. usage: getpkg "package"
local bd="$BUILD_DIR/$1"
local pkgbuild="$bd/PKGBUILD"
comp "$1" && msg '\e[1m'$'\e[33mwarning:' "$1-$OLD is up to date -- reinstalling"
(( CACHE == 1 )) || rm -rf "$bd" >/dev/null 2>&1
[[ -d $bd ]] || mkdir -p "$bd"
if [[ ! -e $pkgbuild || $CACHE -eq 0 ]]; then
git clone "$AUR_ADDR/$1" "$bd" || die "failed to clone $AUR_ADDR/$1"
elif [[ -e $pkgbuild ]]; then
cd "$bd"
git pull || die "failed to pull from $AUR_ADDR/$1"
fi
[[ -e $pkgbuild ]] && cd "$bd" || die "$bd doesn't contain a PKGBUILD"
view "$1" "$pkgbuild" && { yesno "Continue building $1" || return 1; }
buildpkg "$1" "$pkgbuild"
return 0
}
view() { # view PKGBUILD.. usage: view "package" "/path/to/PKGBUILD"
if ! [[ $NOVIEW ]]; then
yesno "View the PKGBUILD for $1" || return 1
if hash nvim >/dev/null 2>&1; then
nvim -n -R -u "$(find /usr/share/nvim/ -wholename '*/macros/less.vim')" "$2"
elif hash vim >/dev/null 2>&1; then
vim -n -R -u "$(find /usr/share/vim/ -wholename '*/macros/less.vim')" "$2"
else
less -P " -- Viewing PKGBUILD for $1 -- (press q to exit)" "$2"
fi
fi
}
buildpkg() { # build package.. usage: buildpkg "package" "/path/to/PKGBUILD"
eval "$(cat "$BUILD_DIR/$1/PKGBUILD")"
(( ${#validpgpkeys[@]} > 0 )) && importkeys ${validpgpkeys[*]}
(( ${#depends[@]} > 0 )) && builddeps "$1" ${depends[*]}
makepkg -sicr makepkg -sicr
} }
update() { importkeys() { # import PGP keys from package.. usage: importkeys ${KEYS[@]}
sudo pacman -Syyu for key in "$@"; do
local installed pacman-key --list-keys | grep -q "$key" && continue
installed="$(pacman -Qqm 2>/dev/null)" msg '\e[33m::' "resolving missing key $key"
if [[ $installed ]]; then gpg --receive-keys "$key"
echo "Info: Updating AUR packages" sudo pacman-key -r "$key" && sudo pacman-key --lsign-key "$key"
for p in $(echo $installed); do
comp "$p" && echo "$p -> up to date" || $SCRIPT --noview --noconfirm "$p"
done
else
echo "Info: No AUR packages installed..."
fi
exit 0
}
install() {
local p="$1"
if pacman -Qsq "^$p$" >/dev/null 2>&1; then
comp "$p" && echo "Warning: $p already installed and up to date"
fi
rm -rf "$BDIR/$p" >/dev/null 2>&1
mkdir -p "$BDIR/$p"
if ! git clone $AUR/$p.git $BDIR/$p; then
die "Error: Git clone failed" 1
elif [[ ! -e $BDIR/$p/PKGBUILD ]]; then
die "Error: $BDIR/$p is missing a PKGBUILD" 1
else
cd "$BDIR/$p"
if [[ $NOVIEW -eq 0 ]]; then
less -P " -- Viewing PKGBUILD for $p -- (press q to exit)" PKGBUILD
fi
if [[ $NOCONF -eq 0 ]]; then
printf "\n\nDo you want to continue installing $p? [Y/n]: " && read -r conf
fi
if [[ $NOCONF -eq 1 || $conf =~ [yY] ]]; then
buildp "$p"
else
echo "Info: Exiting $p build process early"
fi
cd $HOME && rm -rf "$BDIR/$p" >/dev/null 2>&1
fi
}
if ! hash git curl >/dev/null 2>&1; then
die "Error: This requires git and curl installed" 1
fi
# command line arguments
for arg in $@; do case $arg in
--help|-h) usage ;;
--update|-u) update ;;
--noview|-n) NOVIEW=1 ;;
--noconfirm) NOCONF=1 ;;
*) PKGS+=($arg)
esac done
if [[ ${#PKGS[@]} -eq 0 ]]; then
die "Error: Requires at least one package to install" 2
else
for pkg in ${PKGS[@]}; do
if pacman -Ssq "^$pkg$" >/dev/null 2>&1; then
sudo pacman -S "$pkg"
elif curl --silent --head $AUR/packages/$pkg | head -n 1 | grep -q '200'; then
install "$pkg"
else
die "Error: Failed response from $AUR/packages/$pkg" 1
fi
done done
fi }
exit 0 builddeps() { # build package depends.. usage: builddeps "package" ${DEPENDS[@]}
local pdir="$1"; shift
for i in "$@"; do
depend="$(sed 's/[=<>]=\?[0-9]*\?\.\?[0-9]*\?\.\?[0-9]*\?//g' <<< "$i")"
available="$(pacman -Ssq "^$depend$" 2>/dev/null)"
[[ $available ]] && continue
msg '\e[33m::' "resolving AUR dependency -> $depend"
getpkg "$depend" || die "failed to build dependency $depend"
done
cd "$BUILD_DIR/$pdir"
}
#-- Argument parsing & execution --#
pkg_args() { # parse additional command line arguments.. usage: pkg_args $@
for i in "$@"; do case $i in
--noview) NOVIEW="--noview" ;;
--noconfirm) NOCONF="--noconfirm" ;;
--*|-[a-z]) die "invalid option -- '$i'" ;;
*) pacman -Ssq "^$i$" >/dev/null 2>&1 && PAC_PKGS+=("$i") || AUR_PKGS+=("$i")
esac done
}
# catch Ctrl-C and exit
trap 'die "^C caught.."' SIGINT
if (( $# == 0 )); then
die "no operation specified (use -h for help)" 2
elif ! hash pacman git curl >/dev/null 2>&1; then
die "this script requires the following packages installed: pacman git curl"
else
for arg in "$@"; do case $arg in
--help|-h) usage && exit 0 ;;
--update|-u) shift; pkg_args "$@"; prepupdate; break ;;
--install|-i) shift; pkg_args "$@"; prepinstall; break ;;
*) die "invalid option -- '$arg'"
esac done
[[ $CACHE -eq 0 && -d $BUILD_DIR ]] && rm -rf "$BUILD_DIR" >/dev/null 2>&1
fi