aboutsummaryrefslogtreecommitdiff
path: root/sh/profile.d
diff options
context:
space:
mode:
Diffstat (limited to 'sh/profile.d')
-rw-r--r--sh/profile.d/games.sh4
-rw-r--r--sh/profile.d/go.sh8
-rw-r--r--sh/profile.d/grep.sh27
-rw-r--r--sh/profile.d/keychain.sh16
-rw-r--r--sh/profile.d/ls.sh20
-rw-r--r--sh/profile.d/options.sh55
-rw-r--r--sh/profile.d/verse.sh4
7 files changed, 61 insertions, 73 deletions
diff --git a/sh/profile.d/games.sh b/sh/profile.d/games.sh
index b0dd1d35..58db3487 100644
--- a/sh/profile.d/games.sh
+++ b/sh/profile.d/games.sh
@@ -1,4 +1,2 @@
# Add ~/.local/games to PATH if it exists
-if [ -d "$HOME"/.local/games ] ; then
- PATH=$HOME/.local/games:$PATH
-fi
+[ -d "$HOME"/.local/games ] && PATH=$HOME/.local/games:$PATH
diff --git a/sh/profile.d/go.sh b/sh/profile.d/go.sh
deleted file mode 100644
index 86bf9994..00000000
--- a/sh/profile.d/go.sh
+++ /dev/null
@@ -1,8 +0,0 @@
-# Define path for Go code to be installed
-GOPATH=$HOME/.local/gocode
-export GOPATH
-
-# Prepend GOPATH to PATH for the executables if it exists
-if [ -d "$GOPATH"/bin ] ; then
- PATH=$GOPATH/bin:$PATH
-fi
diff --git a/sh/profile.d/grep.sh b/sh/profile.d/grep.sh
deleted file mode 100644
index d1ef3ba1..00000000
--- a/sh/profile.d/grep.sh
+++ /dev/null
@@ -1,27 +0,0 @@
-# Test that we have metadata about what options this system's grep(1) supports,
-# and try to create it if not
-(
- # Create a directory to hold metadata about grep
- gcd=$HOME/.cache/grep
- if ! [ -d "$gcd" ] ; then
- mkdir -p -- "$gcd" || exit
- fi
-
- # Write grep(1)'s --help output to a file, even if it's empty
- if ! [ -f "$gcd"/help ] ; then
- grep --help </dev/null >"$gcd"/help 2>/dev/null || exit
-
- # Iterate through some useful options and create files to show they're
- # available
- set -- binary-files \
- color \
- devices \
- directories \
- exclude \
- exclude-dir
- for opt ; do
- grep -Eq -- --"$opt" "$gcd"/help || continue
- touch -- "$gcd"/"$opt" || exit
- done
- fi
-)
diff --git a/sh/profile.d/keychain.sh b/sh/profile.d/keychain.sh
index 55306ad4..66c23d32 100644
--- a/sh/profile.d/keychain.sh
+++ b/sh/profile.d/keychain.sh
@@ -1,17 +1,9 @@
# ssh-askpass setup
-if command -v ssh-askpass >/dev/null 2>&1 ; then
- SSH_ASKPASS=$(command -v ssh-askpass)
+[ -n "${SSH_ASKPASS:="$(command -v ssh-askpass 2>&1)"}" ] &&
export SSH_ASKPASS
-fi
# keychain setup
-if command -v keychain >/dev/null 2>&1 ; then
+command -v keychain >/dev/null 2>&1 &&
eval "$(TERM=${TERM:-ansi} keychain \
- --eval --ignore-missing --quiet id_dsa id_rsa id_ecsda)"
-
- # Set and export TTY/GPG_TTY for interactive shells
- if [ -t 0 ] ; then
- GPG_TTY=$(tty)
- export GPG_TTY
- fi
-fi
+ --eval --ignore-missing --quick --quiet \
+ id_dsa id_rsa id_ecsda)"
diff --git a/sh/profile.d/ls.sh b/sh/profile.d/ls.sh
deleted file mode 100644
index 0c3754e9..00000000
--- a/sh/profile.d/ls.sh
+++ /dev/null
@@ -1,20 +0,0 @@
-# Test that we have metadata about what options this system's ls(1) supports,
-# and try to create it if not
-(
- # Create a directory to hold metadata about ls(1)
- lcd=$HOME/.cache/ls
- if ! [ -d "$lcd" ] ; then
- mkdir -p -- "$lcd" || exit
- fi
-
- # Write ls(1)'s --help output to a file, even if it's empty
- if ! [ -f "$lcd"/help ] ; then
- ls --help >"$lcd"/help 2>/dev/null || exit
-
- # Iterate through some useful options and create files to show they're
- # available
- if grep -q -- --color "$lcd"/help ; then
- touch -- "$lcd"/color || exit
- fi
- fi
-)
diff --git a/sh/profile.d/options.sh b/sh/profile.d/options.sh
new file mode 100644
index 00000000..aa6bea06
--- /dev/null
+++ b/sh/profile.d/options.sh
@@ -0,0 +1,55 @@
+# Cache the options available to certain programs. Run all this in a subshell
+# (none of its state needs to endure in the session)
+(
+options() { (
+
+ # Check or create the directory to cache the options
+ dir=$HOME/.cache/$1
+
+ # Directory already exists; bail out
+ [ -d "$dir" ] && exit
+
+ # Create the directory
+ mkdir -p -- "$dir" || exit
+ cd -- "$dir" || exit
+
+ # Write grep(1)'s --help output to a file, even if it's empty
+ "$1" --help </dev/null >help 2>/dev/null || exit
+
+ # Shift the program name off; remaining arguments are the options to check
+ shift
+
+ # Iterate through some useful options and create files to show they're
+ # available if found in the help output
+ for opt ; do
+ grep -q -- '[^[:alnum:]]--'"$opt"'[^[:alnum:]]' help &&
+ touch -- "$opt"
+ done
+) ; }
+
+# Cache options for bc(1)
+options bc \
+ quiet
+
+# Cache options for ed(1)
+options ed \
+ verbose
+
+# Cache options for grep(1)
+options grep \
+ binary-files \
+ color \
+ devices \
+ directories \
+ exclude \
+ exclude-dir
+
+# Cache options for ls(1)
+options ls \
+ almost-all \
+ block-size \
+ classify \
+ color \
+ human-readable \
+ time-style
+)
diff --git a/sh/profile.d/verse.sh b/sh/profile.d/verse.sh
index 781d68bc..ef68bb93 100644
--- a/sh/profile.d/verse.sh
+++ b/sh/profile.d/verse.sh
@@ -18,9 +18,7 @@ command -v verse >/dev/null 2>&1 || return
# date); run in a subshell to keep vars out of global namespace
(
now=$(date +%Y-%m-%d)
- if [ -f "$HOME"/.verse ] ; then
- last=$(cat -- "$HOME"/.verse)
- fi
+ [ -f "$HOME"/.verse ] && last=$(cat -- "$HOME"/.verse)
[ "$now" \> "$last" ] || exit
verse
printf '\n'