From ad492c4f41fd13fb45d560257b99a1f085e6fe5d Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Thu, 14 Apr 2016 09:34:42 -0400 Subject: [PATCH] Updates --- bin/arch/packer | 807 +++++++++++++++++++++++++++++++ config/lxpanel/LXDE/panels/panel | 3 - config/terminator/config | 4 +- notes/setup.md | 60 +++ notes/setup.txt | 20 - vim/spell/en.utf-8.add | 5 + vim/spell/en.utf-8.add.spl | Bin 1092 -> 1166 bytes vimrc | 12 +- zsh/aliases | 11 +- zshenv | 6 + 10 files changed, 902 insertions(+), 26 deletions(-) create mode 100755 bin/arch/packer create mode 100644 notes/setup.md delete mode 100644 notes/setup.txt diff --git a/bin/arch/packer b/bin/arch/packer new file mode 100755 index 0000000..d8d3291 --- /dev/null +++ b/bin/arch/packer @@ -0,0 +1,807 @@ +#!/bin/bash +# From https://github.com/keenerd/packer/blob/master/packer +# Use: package installer for Arch Linux +# +# Copyright Matthew Bruenig +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +[[ $PACMAN ]] || PACMAN="pacman" + +# set tmpfile stuff, clean tmpdir +tmpdir="${TMPDIR:-/tmp}/packertmp-$UID" +rm -rf "$tmpdir" &>/dev/null +mkdir -p "$tmpdir" + +makepkgconf='/etc/makepkg.conf' +usermakepkgconf="$HOME/.makepkg.conf" +pacmanconf='/etc/pacman.conf' + +RPCURL="https://aur.archlinux.org/rpc.php?type" +PKGURL="https://aur.archlinux.org" +PKGBURL="https://aur.archlinux.org/cgit/aur.git/plain/PKGBUILD?h" + +if [[ -t 1 && ! $COLOR = "NO" ]]; then + COLOR1='\e[1;39m' + COLOR2='\e[1;32m' + COLOR3='\e[1;35m' + COLOR4='\e[1;36m' + COLOR5='\e[1;34m' + COLOR6='\e[1;33m' + COLOR7='\e[1;31m' + ENDCOLOR='\e[0m' + S='\\' +fi +_WIDTH="$(stty size | cut -d ' ' -f 2)" + +trap ctrlc INT +ctrlc() { + echo + exit +} + +err() { + echo -e "$1" + exit 1 +} + +usage() { + echo 'usage: packer [option] [package] [package] [...]' + echo + echo ' -S - installs package' + echo ' -Syu|-Su - updates all packages, also takes -uu and -yy options' + echo ' -Ss|-Ssq - searches for package' + echo ' -Si - outputs info for package' + echo ' -G - download and extract aur tarball only' + echo + echo ' --quiet - only output package name for searches' + echo ' --ignore - takes a comma-separated list of packages to ignore' + echo ' --noconfirm - do not prompt for any confirmation' + echo ' --noedit - do not prompt to edit files' + echo ' --quickcheck - check for updates and exit' + echo ' --auronly - only do actions for aur' + echo ' --devel - update devel packages during -Su' + echo ' --skipinteg - when using makepkg, do not check md5s' + echo ' --preview - edit pkgbuild before sourcing' + echo ' -h - outputs this message' + exit +} + +# Called whenever anything needs to be run as root ($@ is the command) +runasroot() { + if [[ $UID -eq 0 ]]; then + "$@" + elif sudo -v &>/dev/null && sudo -l "$@" &>/dev/null; then + sudo -E "$@" + else + echo -n "root " + su -c "$(printf '%q ' "$@")" + fi +} + +# Source makepkg.conf file +sourcemakepkgconf() { + . "$makepkgconf" + [[ -r "$usermakepkgconf" ]] && . "$usermakepkgconf" +} + +# Parse IgnorePkg and --ignore, put in globally accessible ignoredpackages array +getignoredpackages() { + IFS=',' read -ra ignoredpackages <<< "$ignorearg" + ignoredpackages+=( $(grep '^ *IgnorePkg' "$pacmanconf" | cut -d '=' -f 2-) ) +} + +# Checks to see if $1 is an ignored package +isignored() { + [[ " ${ignoredpackages[@]} " =~ " $1 " ]] +} + +# Tests whether $1 exists on the aur +existsinaur() { + rpcinfo "$1" + [[ "$(jshon -Qe resultcount -u < "$tmpdir/$1.info")" != "0" ]] +} + +# Tests whether $1 exists in pacman +existsinpacman() { + pacman -Si -- "$1" &>/dev/null +} + +# Tests whether $1 is provided in pacman, sets globally accessibly providepkg var +providedinpacman() { + unset providepkg + IFS=$'\n' read -rd '' -a providepkg < <(pacman -Ssq -- "^$1$") + [[ -n $providepkg ]] +} + +# Tests whether $1 exists in a pacman group +existsinpacmangroup() { + [[ $(pacman -Sgq "$1") ]] +} + +# Tests whether $1 exists locally +existsinlocal() { + pacman -Qq -- "$1" &>/dev/null +} + +# Scrapes the aur deps from PKGBUILDS and puts in globally available dependencies array +scrapeaurdeps() { + pkginfo "$1" "$preview" + . "$tmpdir/$1.PKGBUILD" + IFS=$'\n' + dependencies=( $(echo -e "${depends[*]}\n${makedepends[*]}" | sed -e 's/=.*//' -e 's/>.*//' -e 's/<.*//'| sort -u) ) + unset IFS +} + +# Finds dependencies of package $1 +# Sets pacmandeps and aurdeps array, which can be accessed globally after function runs +finddeps() { + # loop through dependencies, if not installed, determine if pacman or aur deps + pacmandeps=() + aurdeps=() + scrapeaurdeps "$1" + missingdeps=( $(pacman -T "${dependencies[@]}") ) + while [[ $missingdeps ]]; do + checkdeps=() + for dep in "${missingdeps[@]}"; do + if [[ " $1 ${aurdeps[@]} ${pacmandeps[@]} " =~ " $dep " ]]; then + continue + fi + if existsinpacman "$dep"; then + pacmandeps+=("$dep") + elif existsinaur "$dep"; then + if [[ $aurdeps ]]; then + aurdeps=("$dep" "${aurdeps[@]}") + else + aurdeps=("$dep") + fi + checkdeps+=("$dep") + elif providedinpacman "$dep"; then + pacmandeps+=("$providepkg") + else + [[ $option = "install" ]] && err "Dependency \`$dep' of \`$1' does not exist." + echo "Dependency \`$dep' of \`$1' does not exist." + return 1 + fi + done + missingdeps=() + for dep in "${checkdeps[@]}"; do + scrapeaurdeps "$dep" + for depdep in "${dependencies[@]}"; do + [[ $(pacman -T "$depdep") ]] && missingdeps+=("$depdep") + done + done + done + return 0 +} + +# Displays a progress bar ($1 is numerator, $2 is denominator, $3 is candy/normal) +aurbar() { + # Delete line + printf "\033[0G" + + # Get vars for output + beginline=" aur" + beginbar="[" + endbar="] " + perc="$(($1*100/$2))" + width="$(stty size)" + width="${width##* }" + charsbefore="$((${#beginline}+${#1}+${#2}+${#beginbar}+3))" + spaces="$((51-$charsbefore))" + barchars="$(($width-51-7))" + hashes="$(($barchars*$perc/100))" + dashes="$(($barchars-$hashes))" + + # Print output + printf "$beginline %${spaces}s$1 $2 ${beginbar}" "" + + # ILoveCandy + if [[ $3 = candy ]]; then + for ((n=1; n<$hashes; n++)); do + if (( (n==($hashes-1)) && ($dashes!=0) )); then + (($n%2==0)) && printf "\e[1;33mc\e[0m" || printf "\e[1;33mC\e[0m" + else + printf "-" + fi + done + for ((n=1; n<$dashes; n++)); do + N=$(( $n+$hashes )) + (($hashes>0)) && N=$(($N-1)) + (($N%3==0)) && printf "o" || printf " " + done + else + for ((n=0; n<$hashes; n++)); do + printf "#" + done + for ((n=0; n<$dashes; n++)); do + printf "-" + done + fi + printf "%s%3s%%\r" ${endbar} ${perc} +} + +rpcinfo() { + if ! [[ -f "$tmpdir/$1.info" ]]; then + curl -LfGs --data-urlencode "arg=$1" "$RPCURL=info" > "$tmpdir/$1.info" + fi +} + +pkglink() { + rpcinfo $1 + echo "${PKGURL}$(jshon -Q -e results -e URLPath -u < "$tmpdir/$1.info")" +} + +# downloads pkgbuild ($1), edits if $2 is set +pkginfo() { + if ! [[ -f "$tmpdir/$1.PKGBUILD" ]]; then + curl -Lfs "${PKGBURL}=${1}" > "$tmpdir/$1.PKGBUILD" + if [[ $2 ]]; then + # rename for syntax highlighting + cp "$tmpdir/$1.PKGBUILD" "$tmpdir/PKGBUILD" + confirm_edit "${COLOR6}Edit $1 PKGBUILD with \$EDITOR? [Y/n]${ENDCOLOR} " "$tmpdir/PKGBUILD" + mv "$tmpdir/PKGBUILD" "$tmpdir/$1.PKGBUILD" + fi + fi +} + +# Checks if package is newer on aur ($1 is package name, $2 is local version) +aurversionisnewer() { + rpcinfo "$1" + unset aurversion + if existsinaur "$1"; then + aurversion="$(jshon -Q -e results -e Version -u < "$tmpdir/$1.info")" + if [[ "$(LC_ALL=C vercmp "$aurversion" "$2")" -gt 0 ]]; then + return 0 + fi + fi + return 1 +} + +isoutofdate() { + rpcinfo "$1" + [[ "$(jshon -Q -e results -e OutOfDate -u < "$tmpdir/$1.info")" = "1" ]] +} + +# $1 is prompt, $2 is file +confirm_edit() { + if [[ (! -f "$2") || "$noconfirm" || "$noedit" ]]; then + return + fi + echo -en "$1" + if proceed; then + ${EDITOR:-vi} "$2" + fi +} + +# Installs packages from aur ($1 is package, $2 is dependency or explicit) +aurinstall() { + dir="${TMPDIR:-/tmp}/packerbuild-$UID/$1" + sourcemakepkgconf + + # Prepare the installation directory + # If there is an old directory and aurversion is not newer, use old directory + if . "$dir/$1/PKGBUILD" &>/dev/null && ! aurversionisnewer "$1" "$pkgver-$pkgrel"; then + cd "$dir/$1" + else + [[ -d "$dir" ]] && rm -rf "$dir" + mkdir -p "$dir" + cd "$dir" + curl -Lfs "$(pkglink $1)" > "$1.tar.gz" + mkdir "$1" + tar xf "$1.tar.gz" -C "$1" --strip-components=1 + cd "$1" + if [[ $preview && -s "$tmpdir/$1.PKGBUILD" ]]; then + cp "$tmpdir/$1.PKGBUILD" PKGBUILD + fi + # customizepkg + if [[ -f "/etc/customizepkg.d/$1" ]] && type -t customizepkg &>/dev/null; then + echo "Applying customizepkg instructions..." + customizepkg --modify + fi + fi + + # check for missing arch + if [[ ! " ${arch[@]} " =~ " any " ]]; then + if [[ ! " ${arch[@]} " =~ " ${CARCH} " ]]; then + echo -e "${COLOR6}warning:$ENDCOLOR $CARCH missing from arch array" + fi + fi + + # Allow user to edit PKGBUILD + confirm_edit "${COLOR6}Edit $1 PKGBUILD with \$EDITOR? [Y/n]${ENDCOLOR} " PKGBUILD + if ! [[ -f PKGBUILD ]]; then + err "No PKGBUILD found in directory." + fi + + # Allow user to edit .install + unset install + . PKGBUILD + confirm_edit "${COLOR6}Edit $install with \$EDITOR? [Y/n]${ENDCOLOR} " "$install" + + # Installation (makepkg and pacman) + rm -f *$PKGEXT + if [[ $UID -eq 0 ]]; then + makepkg $MAKEPKGOPTS --asroot -f + else + makepkg $MAKEPKGOPTS -f + fi + + [[ $? -ne 0 ]] && echo "The build failed." && return 1 + pkgtarfiles="" + for i in "${pkgname[@]}"; do + pkgtarfiles="$pkgtarfiles $i-*$PKGEXT" + done + if [[ $2 = dependency ]]; then + runasroot $PACMAN ${PACOPTS[@]} --asdeps -U $pkgtarfiles + elif [[ $2 = explicit ]]; then + runasroot $PACMAN ${PACOPTS[@]} -U $pkgtarfiles + fi +} + +# Goes through all of the install tests and execution ($@ is packages to be installed) +installhandling() { + packageargs=("$@") + getignoredpackages + sourcemakepkgconf + # Figure out all of the packages that need to be installed + for package in "${packageargs[@]}"; do + # Determine whether package is in pacman repos + if ! [[ $auronly ]] && existsinpacman "$package"; then + pacmanpackages+=("$package") + elif ! [[ $auronly ]] && existsinpacmangroup "$package"; then + pacmanpackages+=("$package") + elif existsinaur "$package"; then + if finddeps "$package"; then + # here is where dep dupes are created + aurpackages+=("$package") + aurdepends=("${aurdeps[@]}" "${aurdepends[@]}") + pacmandepends+=("${pacmandeps[@]}") + fi + else + err "Package \`$package' does not exist." + fi + done + + # Check if any aur target packages are ignored + for package in "${aurpackages[@]}"; do + if isignored "$package"; then + echo -ne "${COLOR5}:: ${COLOR1}$package is in IgnorePkg/IgnoreGroup. Install anyway?${ENDCOLOR} [Y/n] " + if ! [[ $noconfirm ]]; then + proceed || continue + else + echo + fi + fi + aurtargets+=("$package") + done + + # Check if any aur dependencies are ignored + for package in "${aurdepends[@]}"; do + if isignored "$package"; then + echo -ne "${COLOR5}:: ${COLOR1}$package is in IgnorePkg/IgnoreGroup. Install anyway?${ENDCOLOR} [Y/n] " + if ! [[ $noconfirm ]]; then + if ! proceed; then + echo "Unresolved dependency \`$package'" + unset aurtargets + break + fi + else + echo + fi + fi + done + + # First install the explicit pacman packages, let pacman prompt + if [[ $pacmanpackages ]]; then + runasroot $PACMAN "${PACOPTS[@]}" -S -- "${pacmanpackages[@]}" + fi + if [[ -z $aurtargets ]]; then + exit + fi + # Test if aurpackages are already installed; echo warning if so + for pkg in "${aurtargets[@]}"; do + if existsinlocal "$pkg"; then + localversion="$(pacman -Qs "$pkg" | grep -F "local/$pkg" | cut -d ' ' -f 2)" + if ! aurversionisnewer "$pkg" "$localversion"; then + echo -e "${COLOR6}warning:$ENDCOLOR $pkg-$localversion is up to date -- reinstalling" + fi + fi + done + + # Echo warning if packages are out of date + for pkg in "${aurtargets[@]}" "${aurdepends[@]}"; do + if isoutofdate "$pkg"; then + echo -e "${COLOR6}warning:$ENDCOLOR $pkg is flagged out of date" + fi + done + + # Prompt for aur packages and their dependencies + echo + if [[ $aurdepends ]]; then + num="$((${#aurdepends[@]}+${#aurtargets[@]}))" + echo -e "${COLOR6}Aur Targets ($num):${ENDCOLOR} ${aurdepends[@]} ${aurtargets[@]}" + else + echo -e "${COLOR6}Aur Targets ($((${#aurtargets[@]}))):${ENDCOLOR} ${aurtargets[@]}" + fi + if [[ $pacmandepends ]]; then + IFS=$'\n' read -rd '' -a pacmandepends < \ + <(printf "%s\n" "${pacmandepends[@]}" | sort -u) + echo -e "${COLOR6}Pacman Targets (${#pacmandepends[@]}):${ENDCOLOR} ${pacmandepends[@]}" + fi + + # Prompt to proceed + echo -en "\nProceed with installation? [Y/n] " + if ! [[ $noconfirm ]]; then + proceed || exit + else + echo + fi + + # Install pacman dependencies + if [[ $pacmandepends ]]; then + runasroot $PACMAN --noconfirm --asdeps -S -- "${pacmandepends[@]}" || err "Installation failed." + fi + + # Install aur dependencies + if [[ $aurdepends ]]; then + for dep in "${aurdepends[@]}"; do + aurinstall "$dep" "dependency" + done + fi + + # Install the aur packages + for package in "${aurtargets[@]}"; do + scrapeaurdeps "$package" + if pacman -T "${dependencies[@]}" &>/dev/null; then + aurinstall "$package" "explicit" + else + echo "Dependencies for \`$package' are not met, not building..." + fi + done +} + +run_quick_check() { + bigurl="https://aur.archlinux.org/rpc.php?type=multiinfo" + for p in $(pacman -Qqm); do + bigurl="$bigurl&arg\[\]=$p" + done + parsed_aur="$(curl -s "$bigurl" | \ + jshon -e results -a -e Name -u -p -e Version -u | \ + sed 's/^$/-/' | paste -s -d '\t\n' | sort)" + packages="$(expac -Q '%n\t%v' | sort)" + comm -23 <(echo "$parsed_aur") <(echo "$packages") | cut -f 1 + if [[ $auronly == 1 ]]; then + return + fi + # see https://mailman.archlinux.org/pipermail/pacman-dev/2011-October/014673.html + # (note to self, get that merged already...) + if [[ -z $CHECKUPDATE_DB ]]; then + CHECKUPDATE_DB="${TMPDIR:-/tmp}/checkup-db-${USER}/" + fi + eval $(awk '/DBPath/ {print $1$2$3}' $pacmanconf) + DBPath="${DBPath:-/var/lib/pacman/}" + mkdir -p "$CHECKUPDATE_DB" + ln -s "${DBPath}/local" "$CHECKUPDATE_DB" &> /dev/null + fakeroot pacman -Sqy --dbpath "$CHECKUPDATE_DB" &> /dev/null + pacman -Qqu --dbpath "$CHECKUPDATE_DB" 2> /dev/null +} + +# proceed with installation prompt +proceed() { + read -n 1 + echo + case "$REPLY" in + 'Y'|'y'|'') return 0 ;; + *) return 1 ;; + esac +} + +# process busy loop +nap() { + while (( $(jobs | wc -l) >= 8 )); do + jobs > /dev/null + done +} + +# Argument parsing +[[ $1 ]] || usage +packageargs=() +while [[ $1 ]]; do + case "$1" in + '-S') option=install ;; + '-Ss') option=search ;; + '-Ssq'|'-Sqs') option=search ; quiet='1' ;; + '-Si') option=info ;; + -S*u*) option=update ; pacmanarg="$1" ;; + '-G') option=download ;; + '-h'|'--help') usage ;; + '--quiet') quiet='1' ;; + '--ignore') ignorearg="$2" ; PACOPTS+=("--ignore" "$2") ; shift ;; + '--noconfirm') noconfirm='1' PACOPTS+=("--noconfirm");; + '--noedit') noedit='1' ;; + '--auronly') auronly='1' ;; + '--quickcheck') quickcheck='1' ;; + '--devel') devel='1' ;; + '--skipinteg') MAKEPKGOPTS="--skipinteg" ;; + '--preview') preview='1' ;; + '--') shift ; packageargs+=("$@") ; break ;; + -*) echo "packer: Option \`$1' is not valid." ; exit 5 ;; + *) packageargs+=("$1") ;; + esac + shift +done + +# check for new packages +if [[ $quickcheck == 1 ]]; then + run_quick_check + exit +fi + +# Sanity checks +[[ $option ]] || option="searchinstall" +[[ $option != "update" && -z $packageargs ]] && err "Must specify a package." + +# Install (-S) handling +if [[ $option = install ]]; then + installhandling "${packageargs[@]}" + exit +fi + +# Update (-Su) handling +if [[ $option = update ]]; then + getignoredpackages + sourcemakepkgconf + # Pacman update + if ! [[ $auronly ]]; then + runasroot $PACMAN "${PACOPTS[@]}" "$pacmanarg" + fi + + # Aur update + echo -e "${COLOR5}:: ${COLOR1}Synchronizing aur database...${ENDCOLOR}" + IFS=$'\n' read -rd '' -a packages < <(pacman -Qm) + newpackages=() + checkignores=() + total="${#packages[@]}" + grep -q '^ *ILoveCandy' "$pacmanconf" && bartype='candy' || bartype='normal' + + if [[ $devel ]]; then + for ((i=0; i<$total; i++)); do + aurbar "$((i+1))" "$total" "$bartype" + pkg="${packages[i]%% *}" + if isignored "$pkg"; then + checkignores+=("${packages[i]}") + continue + fi + pkginfo "$pkg" & + nap + done + wait + for ((i=0; i<$total; i++)); do + pkg="${packages[i]%% *}" + ver="${packages[i]##* }" + if [[ ! -s "$tmpdir/$pkg.PKGBUILD" ]]; then + continue + fi + if isignored "$pkg"; then + continue + fi + unset _darcstrunk _cvsroot _gitroot _svntrunk _bzrtrunk _hgroot + . "$tmpdir/$pkg.PKGBUILD" + if [[ "$(LC_ALL=C vercmp "$pkgver-$pkgrel" "$ver")" -gt 0 ]]; then + newpackages+=("$pkg") + elif [[ ${_darcstrunk} || ${_cvsroot} || ${_gitroot} || ${_svntrunk} || ${_bzrtrunk} || ${_hgroot} ]]; then + newpackages+=("$pkg") + fi + done + else + for ((i=0; i<$total; i++)); do + aurbar "$((i+1))" "$total" "$bartype" + pkg="${packages[i]%% *}" + rpcinfo "$pkg" & + nap + done + wait + for ((i=0; i<$total; i++)); do + pkg="${packages[i]%% *}" + ver="${packages[i]##* }" + if isignored "$pkg"; then + checkignores+=("${packages[i]}") + elif aurversionisnewer "$pkg" "$ver"; then + newpackages+=("$pkg") + fi + done + fi + echo + + echo -e "${COLOR5}:: ${COLOR1}Starting full aur upgrade...${ENDCOLOR}" + + # Check and output ignored package update info + for package in "${checkignores[@]}"; do + if aurversionisnewer "${package%% *}" "${package##* }"; then + echo -e "${COLOR6}warning:${ENDCOLOR} ${package%% *}: ignoring package upgrade (${package##* } => $aurversion)" + fi + done + + # Now for the installation part + if [[ $newpackages ]]; then + auronly='1' + installhandling "${newpackages[@]}" + fi + echo " local database is up to date" +fi + +# Download (-G) handling +if [[ $option = download ]]; then + for package in "${packageargs[@]}"; do + if existsinaur "$package"; then + pkglist+=("$package") + else + err "Package \`$package' does not exist on aur." + fi + done + + for package in "${pkglist[@]}"; do + curl -Lfs "$(pkglink $package)" > "$package.tar.gz" + mkdir "$package" + tar xf "$package.tar.gz" -C "$package" --strip-components=1 + done +fi + +# Search (-Ss) handling +if [[ $option = search || $option = searchinstall ]]; then + # Pacman searching + if ! [[ $auronly ]]; then + if [[ $quiet ]]; then + results="$(pacman -Ssq -- "${packageargs[@]}")" + else + results="$(pacman -Ss -- "${packageargs[@]}")" + results="$(sed -r "s|^[^ ][^/]*/|$S${COLOR3}&$S${COLOR1}|" <<< "$results")" + results="$(sed -r "s|^([^ ]+) ([^ ]+)(.*)$|\1 $S${COLOR2}\2$S${ENDCOLOR}\3|" <<< "$results")" + fi + if [[ $option = search ]]; then + echo -e "$results" | fmt -"$_WIDTH" -s + else # interactive + echo -e "$results" | fmt -"$_WIDTH" -s | nl -v 0 -w 1 -s ' ' -b 'p^[^ ]' + fi | sed '/^$/d' + pacname=( $(pacman -Ssq -- "${packageargs[@]}") ) + pactotal="${#pacname[@]}" + else + pactotal=0 + fi + + # Aur searching and tmpfile preparation + for package in "${packageargs[@]}"; do + curl -LfGs --data-urlencode "arg=$package" "$RPCURL=search" | \ + jshon -Q -e results -a -e Name -u -p -e Version -u -p -e NumVotes -u -p -e Description -u | \ + sed 's/^$/-/' | paste -s -d "\t\t\t\n" | sort -nr -k 3 > "$tmpdir/$package.search" & + done + wait + cp "$tmpdir/${packageargs[0]}.search" "$tmpdir/search.results" + for ((i=1 ; i<${#packageargs[@]} ; i++)); do + grep -xFf "$tmpdir/search.results" "$tmpdir/${packageargs[$i]}.search" > "$tmpdir/search.results-2" + mv "$tmpdir/search.results-2" "$tmpdir/search.results" + done + sed -i '/^$/d' "$tmpdir/search.results" + + # Prepare tmp file and arrays + IFS=$'\n' read -rd '' -a aurname < <(cut -f 1 "$tmpdir/search.results") + aurtotal="${#aurname[@]}" + alltotal="$(($pactotal+$aurtotal))" + # Echo out the -Ss formatted package information + + IFS=$'\t\n' + if [[ $option = search ]]; then + if [[ $quiet ]]; then + printf "%s\n" ${aurname[@]} + elif [[ -s "$tmpdir/search.results" ]]; then + printf "${COLOR3}aur/${COLOR1}%s ${COLOR2}%s${ENDCOLOR} (%s)\n %s\n" $(cat "$tmpdir/search.results") + fi + else + # interactive + if [[ $quiet ]]; then + nl -v ${pactotal:-0} -w 1 -s ' ' <(cut -f 1 "$tmpdir/search.results") + elif [[ -s "$tmpdir/search.results" ]]; then + printf "%d ${COLOR3}aur/${COLOR1}%s ${COLOR2}%s${ENDCOLOR} (%s)\n %s\n" $(nl -v ${pactotal:-0} -w 1 < "$tmpdir/search.results") + fi + fi | fmt -"$_WIDTH" -s + unset IFS + + # Prompt and install selected numbers + if [[ $option = searchinstall ]]; then + pkglist=() + allpackages=( "${pacname[@]}" "${aurname[@]}" ) + + # Exit if there are no matches + [[ $allpackages ]] || exit + + # Prompt for numbers + echo + echo -e "${COLOR2}Type numbers to install. Separate each number with a space.${ENDCOLOR}" + echo -ne "${COLOR2}Numbers: ${ENDCOLOR}" + read -r + + # Parse answer + if [[ $REPLY ]]; then + for num in $REPLY; do + if [[ $num -lt $alltotal ]]; then + pkglist+=("${allpackages[$num]}") + else + err "Number \`$num' is not assigned to any of the packages." + fi + done + fi + + # Call installhandling to take care of the packages chosen + installhandling "${pkglist[@]}" + fi + + # Remove the tmpfiles + rm -f "$tmpdir/*search" &>/dev/null + rm -f "$tmpdir/search.result" &>/dev/null + exit +fi + +# Info (-Si) handling +if [[ $option = info ]]; then + # Pacman info check + sourcemakepkgconf + for package in "${packageargs[@]}"; do + if ! [[ $auronly ]] && existsinpacman "$package"; then + results="$(pacman -Si -- "$package")" + results="$(sed -r "s|^(Repository[^:]*:)(.*)$|\1$S${COLOR3}\2$S${ENDCOLOR}|" <<< "$results")" + results="$(sed -r "s|^(Name[^:]*:)(.*)$|\1$S${COLOR1}\2$S${ENDCOLOR}|" <<< "$results")" + results="$(sed -r "s|^(Version[^:]*:)(.*)$|\1$S${COLOR2}\2$S${ENDCOLOR}|" <<< "$results")" + results="$(sed -r "s|^(URL[^:]*:)(.*)$|\1$S${COLOR4}\2$S${ENDCOLOR}|" <<< "$results")" + results="$(sed -r "s|^[^ ][^:]*:|$S${COLOR1}&$S${ENDCOLOR}|" <<< "$results")" + echo -e "$results" + exit + else # Check to see if it is in the aur + pkginfo "$package" "$preview" + [[ -s "$tmpdir/$package.PKGBUILD" ]] || err "${COLOR7}error:${ENDCOLOR} package '$package' was not found" + . "$tmpdir/$package.PKGBUILD" + + # Echo out the -Si formatted package information + # Retrieve each element in order and echo them immediately + echo -e "${COLOR1}Repository : ${COLOR3}aur" + echo -e "${COLOR1}Name : $pkgname" + echo -e "${COLOR1}Version : ${COLOR2}$pkgver-$pkgrel" + echo -e "${COLOR1}URL : ${COLOR4}$url" + echo -e "${COLOR1}Licenses : ${ENDCOLOR}${license[@]}" + echo -e "${COLOR1}Groups : ${ENDCOLOR}${groups[@]:-None}" + echo -e "${COLOR1}Provides : ${ENDCOLOR}${provides[@]:-None}" + echo -e "${COLOR1}Depends On : ${ENDCOLOR}${depends[@]}" + echo -e "${COLOR1}Make Depends : ${ENDCOLOR}${makedepends[@]}" + echo -e -n "${COLOR1}Optional Deps : ${ENDCOLOR}" + + len="${#optdepends[@]}" + if [[ $len -eq 0 ]]; then + echo "None" + else + for ((i=0 ; i<$len ; i++)); do + if [[ $i = 0 ]]; then + echo "${optdepends[$i]}" + else + echo -e " ${optdepends[$i]}" + fi + done + fi + + echo -e "${COLOR1}Conflicts With : ${ENDCOLOR}${conflicts[@]:-None}" + echo -e "${COLOR1}Replaces : ${ENDCOLOR}${replaces[@]:-None}" + echo -e "${COLOR1}Architecture : ${ENDCOLOR}${arch[@]}" + echo -e "${COLOR1}Description : ${ENDCOLOR}$pkgdesc" + echo + fi + done +fi diff --git a/config/lxpanel/LXDE/panels/panel b/config/lxpanel/LXDE/panels/panel index 344349b..b1e5839 100644 --- a/config/lxpanel/LXDE/panels/panel +++ b/config/lxpanel/LXDE/panels/panel @@ -82,9 +82,6 @@ Plugin { Button { id=/usr/share/applications/slack.desktop } - Button { - id=/usr/share/applications/telegramdesktop.desktop - } Button { id=menu://applications/chrome-apps/chrome-hmjkmjkepdijhoojdojkdfohbdgmmhki-Default.desktop } diff --git a/config/terminator/config b/config/terminator/config index 0f0e853..b8ba820 100644 --- a/config/terminator/config +++ b/config/terminator/config @@ -1,5 +1,6 @@ [global_config] enabled_plugins = LaunchpadCodeURLHandler, SearchGoogle, APTURLHandler, LaunchpadBugURLHandler + suppress_multiple_term_dialog = True title_hide_sizetext = True window_state = maximise [keybindings] @@ -72,13 +73,14 @@ type = VPaned [[[terminal10]]] command = lein repl; zsh - directory = /home/michael/ + directory = /home/michael/.work-files/dive-networks/dive-web-app/ order = 1 parent = child6 profile = default type = Terminal uuid = a51152d4-6cb9-4d72-97fc-39bdf1376818 [[[terminal11]]] + command = "" directory = /home/michael/.work-files/dive-networks/dive-web-app/ order = 1 parent = child1 diff --git a/notes/setup.md b/notes/setup.md new file mode 100644 index 0000000..e03dfd7 --- /dev/null +++ b/notes/setup.md @@ -0,0 +1,60 @@ +# Setting up Ruby + +* Install rvm +* Install bundler +* Install Ruby Docs + gem install rdoc-data + rdoc-data --install + # to regenerate all gem docs + gem rdoc --all --overwrite + + +# Setup Vim + +Map to in System Preferences -> Keyboard -> Modifier Keys. Now can leave insert mode. + + +# Setup Git + +Vim might not work properly when writing commit messages. To fix, run: + + $ git config --global core.editor /usr/bin/vim + + +# Setup Arch + +* Lots to do but unfortunately I didn't write it all down! +* Fix fonts by placing the following XML into `/etc/fonts/conf.avail/29-prettify.conf` + and then symlinking: `ln -s /etc/fonts/conf.avail/29-prettify.conf /etc/fonts/conf.d/29-prettify.conf` + + ``` + + + + + + rgb + + + + + true + + + + + hintslight + + + + + true + + + + + lcddefault + + + + ``` diff --git a/notes/setup.txt b/notes/setup.txt deleted file mode 100644 index c65539c..0000000 --- a/notes/setup.txt +++ /dev/null @@ -1,20 +0,0 @@ -Setting up Ruby ---------------- - -* Install rvm -* Install bundler -* Install Ruby Docs - gem install rdoc-data - rdoc-data --install - # to regenerate all gem docs - gem rdoc --all --overwrite - -Setup Vim ---------- -Map to in System Preferences -> Keyboard -> Modifier Keys. Now can leave insert mode. - -Setup Git ---------- -Vim might not work properly when writing commit messages. To fix, run: - - $ git config --global core.editor /usr/bin/vim diff --git a/vim/spell/en.utf-8.add b/vim/spell/en.utf-8.add index 40dbf2e..a476bdf 100644 --- a/vim/spell/en.utf-8.add +++ b/vim/spell/en.utf-8.add @@ -86,3 +86,8 @@ refactor rebasing Workflow wiki +workflow +Leiningen +repo +fullscreen +programmatically diff --git a/vim/spell/en.utf-8.add.spl b/vim/spell/en.utf-8.add.spl index cbd1c0ca6c8db0b5fc2eb1ab9a128e306b6116a0..d3ebb611197015a1ed8d586fe97a7cf173cf56c2 100644 GIT binary patch literal 1166 zcmYLIyN=Z`6tsP_d;%R2MU>qZiWLnF&@2dqvO?zPvMK59qoB5Zs&1I0P1*FE*Hd0oOY(}hIdM7|rRjoWs{M1{VA zA%_c-Tcbv!ay?5Bky3B*HE3&$8IfRsr3baS)j?OnD%|l}-N7&@w^31zJ5&(#2AL^?K3@5dqO1;G#toQTrPQ0~<<W^)=+* j|BwpRvH|NPy#j-J^a4!(FXy#j*OK~!q^6HWYNh@HTmaaQ literal 1092 zcmYLI%Z}7A5Oh0P{(xh|A&TaXwBin27PJ!5A|#G^IEiN*C&bA-Zu+d> zpt_v}jS_pRyQ{0(&X>FUFd64w|4~Z+epyy^W7@8_`@xUX9G3NXx+K%QYCDlm6SWIO zN)>^WtQ{>h(nO9*x{zgT=My)sK(WuexE2mEM-4Jds-^Ofx-l$?-H%$QH60MBkiz6f ztDsdys}wQP&>sJ0GFs~Zf*Fwst@R^$YNf06&Z4@r=Az1^bsLUQ;3*(^21V?>&_D)A z&z0-=FSc+Ku3ZgYZ>&}|WX+tFH{|sFe23`4hTT3SZ@s%rD@RpbdGZ`T2y#c zkEq*o(o+C(0i%sYuNHLT=?O*7Gvp3@MdY-vr8e_TS+#ybBJS;hFDr;{nWz?OZa5<< zQ!AqZw`rQv+AbH}Bjv?XXT*nQz5~#C-LmQtD&+ t?(Wl9N!h+6dVu%m??^!}yN`F`J$uOBqSOD;e-P|Js6Pue=NM2c^%tmD$?5 1 && line("'\"") <= line("$") | exe "normal! g`\"" | endif autocmd FileType ruby,haml,eruby,yaml,html,javascript,sass,cucumber set ai sw=2 sts=2 et - autocmd FileType python set sw=2 sts=2 et + autocmd FileType python set sw=4 sts=4 et " Indent p tags autocmd FileType html,eruby if g:html_indent_tags !~ '\\|p\>' | let g:html_indent_tags .= '\|p\|li\|dt\|dd' | endif @@ -215,6 +215,16 @@ augroup END """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" :set statusline=%<%f\ (%{&ft})\ %-4(%m%)%=%-19(%3l,%02c%03V%) +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +" HIGHLIGHT TODO, NOTE, FIXME, etc +""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +augroup vimrc_todo + au! + au Syntax * syn match MyTodo /\v<(WARNING|FIXME|NOTE|TODO|OPTIMIZE|QUESTION):/ + \ containedin=.*Comment,vimCommentTitle +augroup END +hi def link MyTodo Todo + """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " GIT """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" diff --git a/zsh/aliases b/zsh/aliases index be28abd..157856f 100644 --- a/zsh/aliases +++ b/zsh/aliases @@ -35,6 +35,7 @@ alias cls=clear alias code='cd ~/code' alias cpr='cp -r' alias cw='compass watch' +alias dc='gdc' alias dot='cd ~/.' alias duh='du -csh' alias functions='vim ~/.dotfiles/zsh/functions' @@ -69,8 +70,9 @@ alias mcp='mvn clean package' alias opensource='cd ~/.personal-files/dev/open-source' alias patch='git format-patch HEAD^ --stdout > patch.diff' alias pi='yaourt -S' # wrapper around Arch Pacman -alias pr='yaourt -R' alias po='pacman -Qdt' # see orphaned packages +alias pr='yaourt -R' +alias pss='sudo pacman -Syu' alias pu='yaourt -U' alias reguard='killall -9 ruby ; guard' alias r='rails' @@ -106,6 +108,7 @@ alias amend='echo "use am instead"' alias g='gst' alias ga='git add -A :/' alias gaa='git add -A' +alias gaap='git add -Ap' alias gau='git add --update' alias gb='git branch' alias gbd='git branch -D' @@ -170,6 +173,7 @@ alias gpom='git push origin master' alias gpr='git pull --rebase' alias gpt='git push --tags' alias gr='git reset' +alias gr1='git reset HEAD^1' alias grb='git rebase' alias grba='git rebase --abort' alias grbc='git rebase --continue' @@ -182,19 +186,23 @@ alias grboi='git fetch origin master && git rebase origin/master -i' alias grbum='git fetch upstream master && git rebase upstream/master' alias gre='git remote' alias grea='git remote add' +alias gremo='git remote remove origin; git remote add origin' alias greao='git remote add origin' alias gref='git reflog' alias grev='git remote -v' alias grm='git rm' alias grmr='git rm -r' +alias grp='git reset -p' alias gsnapshot='git stash save "snapshot: $(date)" && git stash apply "stash@{0}"' alias gsh='git show' alias gst='git status' alias gs='git stash' +alias gsk='git stash -k -u' alias gss='git stash save' alias gsd='git stash drop' alias gsdl='git stash drop stash@{0}' alias gsl='git stash list' +alias gsi='git stash -p' alias gsp='git stash pop' alias gsp1='git stash pop stash@{0}' alias gsp2='git stash pop stash@{1}' @@ -220,6 +228,7 @@ alias pn='vim ~/.personal-files/documents/Notes/stack.txt' alias writing='cd ~/.personal-files/brain/writing' # Projects +alias dev='cd ~/.personal-files/dev' alias projects='cd ~/.personal-files/dev/projects' alias dot='cd ~/.dotfiles' alias work='cd ~/.work-files' diff --git a/zshenv b/zshenv index 8901e7b..68e39b7 100644 --- a/zshenv +++ b/zshenv @@ -1,3 +1,5 @@ +platform=`uname` + # Unbreak broken, non-colored terminal export TERM=xterm-256color @@ -24,6 +26,10 @@ export ANSIBLE_HOSTS=~/.ansible_hosts export LEIN_FAST_TRAMPOLINE=y export ANDROID_HOME=/usr/local/opt/android-sdk +if [[ $platform == 'Linux' ]]; then + export LD_LIBRARY_PATH="/usr/lib/jvm/java-8-openjdk/jre/lib/amd64" +fi + #export PATH=/usr/local/sbin:/usr/local/bin:${PATH} path=($HOME/bin ${ANSIBLE_DIR}/bin ${RBENV_PATH}/bin $HOME/.vim/scripts $path)