summaryrefslogtreecommitdiff
path: root/.local
diff options
context:
space:
mode:
authorLuke Shumaker <lukeshu@sbcglobal.net>2015-01-29 12:13:43 -0500
committerLuke Shumaker <lukeshu@sbcglobal.net>2015-01-29 12:13:43 -0500
commitcbd6ae1cc7374e9c825642751bfa146c7cc0a5a8 (patch)
tree4deb4424b115b3215bc696ac467149368b97d79d /.local
parentaf7fca016ab0e83c129147f8102dc8ee893571a8 (diff)
parenta19e716cf26fa4a67fe676d0822c96425d528903 (diff)
Merge branch 'gluglugt60-par'
Diffstat (limited to '.local')
-rw-r--r--.local/.gitignore1
-rwxr-xr-x.local/bin/config-path67
-rwxr-xr-x.local/bin/pick10
-rwxr-xr-x.local/bin/x-pdf3
-rwxr-xr-x.local/bin/x-terminal-emulator3
-rwxr-xr-x.local/bin/x-www-browser3
-rwxr-xr-x.local/bin/xmessage2
-rw-r--r--.local/lib/path.sh9
-rw-r--r--.local/lib/xdg.sh23
9 files changed, 52 insertions, 69 deletions
diff --git a/.local/.gitignore b/.local/.gitignore
new file mode 100644
index 0000000..8d0c87d
--- /dev/null
+++ b/.local/.gitignore
@@ -0,0 +1 @@
+/share/
diff --git a/.local/bin/config-path b/.local/bin/config-path
index 6b9019c..f4c2342 100755
--- a/.local/bin/config-path
+++ b/.local/bin/config-path
@@ -1,16 +1,22 @@
#!/bin/bash
-# All the prefixes to consider
-prefixes=(
- "$HOME"
- "$HOME/.local.`uname -m`"
- "$HOME/.local"
- "$HOME/.prefix.`uname -m`"
- "$HOME/.prefix"
- "$HOME"/.gem/ruby/*
-)
-
-######################################################################
+the_guts() {
+ # Add generic prefixes
+ add_prefix "$HOME"
+ add_prefix "$HOME/.local.$(uname -m)"
+ add_prefix "$HOME/.local"
+ add_prefix "$HOME/.prefix.$(uname -m)"
+ add_prefix "$HOME/.prefix"
+
+ # Add rubygem prefixes
+ local dir
+ for dir in "$HOME"/.gem/*; do
+ # Only add it if we have that type of ruby
+ if type "${dir##*/}" &>/dev/null; then
+ add_prefix "$dir"/*
+ fi
+ done
+}
in_array() {
local needle=$1; shift
@@ -22,30 +28,41 @@ in_array() {
return 1
}
-# Import existing values
-IFS=: paths=($PATH)
-IFS=: rubylibs=($RUBYLIB)
+add_prefix() {
+ local prefix=$1
+ local dir
-# Scan through prefixes
-for prefix in "${prefixes[@]}"; do
# PATH
dir="$prefix/bin"
if [[ -d "$dir" ]] && ! in_array "$dir" "${paths[@]}"; then
paths=("$dir" "${paths[@]}")
fi
+
# RUBYLIB
dir="$prefix/lib"
if [[ -d "$dir" ]] && ! in_array "$dir" "${rubylibs[@]}"; then
rubylibs=("$dir" "${rubylibs[@]}")
fi
-done
+}
-# Finally, print our values
-IFS=: PATH="${paths[*]}"
-IFS=: RUBYLIB="${rubylibs[*]}"
+main() {
+ # Import existing values
+ declare -ga paths rubylibs
+ IFS=: paths=($PATH)
+ IFS=: rubylibs=($RUBYLIB)
+
+ the_guts
+
+ # Put our values into the env variables
+ IFS=: PATH="${paths[*]}"
+ IFS=: RUBYLIB="${rubylibs[*]}"
+
+ # Finally, print the values
+ # The sed bit here is the only time we call an external program
+ {
+ declare -p PATH
+ declare -p RUBYLIB
+ } | sed 's/^declare \(-\S* \)*//'
+}
-# The sed bit here is the only time we call an external program
-{
- declare -p PATH
- declare -p RUBYLIB
-} | sed 's/^declare \(-\S* \)*//'
+main
diff --git a/.local/bin/pick b/.local/bin/pick
index ed2d44d..7458041 100755
--- a/.local/bin/pick
+++ b/.local/bin/pick
@@ -19,8 +19,8 @@ if [[ $1 = -s ]]; then
shift
# Scan to find a running instance
for prog in "$@"; do
- if [[ -n "`pgrep $prog`" ]]; then
- printf '%s\n' "$prog"
+ if [[ -n "$(pgrep "${prog%% *}")" ]]; then
+ printf -- '%s\n' "$prog"
exit 0
fi
done
@@ -28,11 +28,11 @@ fi
# Scan to find one that is installed
for prog in "$@"; do
- if [[ -x "`which $prog 2>/dev/null`" ]]; then
- printf '%s\n' "$prog"
+ if [[ -x "$(which "${prog%% *}" 2>/dev/null)" ]]; then
+ printf -- '%s\n' "$prog"
exit 0
fi
done
-printf '%s\n' "$cmd: no suitable program found"
+printf -- '%s\n' "$cmd: no suitable program found" >&2
exit 1
diff --git a/.local/bin/x-pdf b/.local/bin/x-pdf
index 3610fde..8f9ef60 100755
--- a/.local/bin/x-pdf
+++ b/.local/bin/x-pdf
@@ -1,4 +1,3 @@
#!/bin/sh
-`pick zathura mupdf okular evince xpdf` "$@"
-exit $?
+exec $(pick atril zathura mupdf okular evince xpdf 'emacsclient -c') "$@"
diff --git a/.local/bin/x-terminal-emulator b/.local/bin/x-terminal-emulator
index 049b081..2e158cf 100755
--- a/.local/bin/x-terminal-emulator
+++ b/.local/bin/x-terminal-emulator
@@ -1,4 +1,3 @@
#!/bin/sh
-`pick emacsterm urxvt gnome-terminal xterm` "$@"
-exit $?
+exec $(pick 'emacsterm -c' 'urxvt' 'xterm' 'gnome-terminal') "$@"
diff --git a/.local/bin/x-www-browser b/.local/bin/x-www-browser
index bbd8943..b0b05e0 100755
--- a/.local/bin/x-www-browser
+++ b/.local/bin/x-www-browser
@@ -1,4 +1,3 @@
#!/bin/sh
-`pick -s conkeror iceweasel icecat firefox` "$@"
-exit $?
+exec $(pick -s iceweasel icecat firefox conkeror) "$@"
diff --git a/.local/bin/xmessage b/.local/bin/xmessage
index bd30b5e..08fd95e 100755
--- a/.local/bin/xmessage
+++ b/.local/bin/xmessage
@@ -1,2 +1,2 @@
#!/bin/sh
-gxmessage $@ -fn 'Monospace'
+exec gxmessage $@ -fn 'Monospace'
diff --git a/.local/lib/path.sh b/.local/lib/path.sh
deleted file mode 100644
index a45f8fd..0000000
--- a/.local/lib/path.sh
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/sh
-
-if type config-path &>/dev/null; then
- config_path=config-path
-else
- # Bootstrap finding config-path
- config_path="$HOME/.local/bin/config-path"
-fi
-eval "$("$config_path" | sed 's/^/export /')"
diff --git a/.local/lib/xdg.sh b/.local/lib/xdg.sh
deleted file mode 100644
index 2241d2e..0000000
--- a/.local/lib/xdg.sh
+++ /dev/null
@@ -1,23 +0,0 @@
-#!/bin/bash
-# This should be readable by /bin/sh, but I'm going to assume bash.
-
-# Sets up XDG environmental variables, so programs using them don't have to
-# worry about checking if they are set.
-# http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
-
-[[ -n $XDG_DATA_HOME ]] || export XDG_DATA_HOME="$HOME/.local/share"
-[[ -n $XDG_CONFIG_HOME ]] || export XDG_CONFIG_HOME="$HOME/.config"
-[[ -n $XDG_DATA_DIRS ]] || export XDG_DATA_DIRS="/usr/local/share/:/usr/share/"
-[[ -n $XDG_CONFIG_DIRS ]] || export XDG_CONFIG_DIRS="/etc/xdg"
-[[ -n $XDG_CACHE_HOME ]] || export XDG_CACHE_HOME="$HOME/.cache"
-
-# Check if XDG_RUNTIME_DIR is set, but has a bogus setting
-if [[ -n $XDG_RUNTIME_DIR ]] && [[ ! -d $XDG_RUNTIME_DIR ]]; then
- unset XDG_RUNTIME_DIR
-fi
-
-# Set XDG_RUNTIME_DIR if we can
-if [[ -z $XDG_RUNTIME_DIR ]] && [[ -n $TMPDIR ]]; then
- export XDG_RUNTIME_DIR="$TMPDIR/xdg-runtime"
- install -dm0700 "$XDG_RUNTIME_DIR"
-fi