aboutsummaryrefslogtreecommitdiff
path: root/bash
diff options
context:
space:
mode:
authorTom Ryder <tom@sanctum.geek.nz>2014-10-10 16:25:47 +1300
committerTom Ryder <tom@sanctum.geek.nz>2014-10-10 16:25:47 +1300
commite1401360121785b7dd7b5b5d7b7ef5b337e5bb39 (patch)
treeed7e1e9c7020e17d7acbe5a6bb173d6f6d94d854 /bash
parentRemove brace expansion for grep alias (diff)
downloaddotfiles-e1401360121785b7dd7b5b5d7b7ef5b337e5bb39.tar.gz
dotfiles-e1401360121785b7dd7b5b5d7b7ef5b337e5bb39.zip
Move array decs inline, remove quotes
Diffstat (limited to 'bash')
-rw-r--r--bash/bashrc.d/cf.bash3
-rw-r--r--bash/bashrc.d/grep.bash9
-rw-r--r--bash/bashrc.d/ls.bash2
-rw-r--r--bash/bashrc.d/mysql.bash6
4 files changed, 7 insertions, 13 deletions
diff --git a/bash/bashrc.d/cf.bash b/bash/bashrc.d/cf.bash
index db715c2f..66917375 100644
--- a/bash/bashrc.d/cf.bash
+++ b/bash/bashrc.d/cf.bash
@@ -19,9 +19,8 @@ cf() {
# Count files and print; use a subshell so options are unaffected
(
- declare -a files
shopt -s dotglob nullglob
- files=("$dir"/*)
+ declare -a files=("$dir"/*)
printf '%d\t%s\n' "${#files[@]}" "$dir"
)
}
diff --git a/bash/bashrc.d/grep.bash b/bash/bashrc.d/grep.bash
index b2ff5daf..de225347 100644
--- a/bash/bashrc.d/grep.bash
+++ b/bash/bashrc.d/grep.bash
@@ -1,15 +1,12 @@
# Return appropriate options for grep
grepopts() {
+ # Start with ignoring binary files
+ local -a grepopts=(-I)
+
# Snarf the output of `grep --help` into a variable
local grephelp=$(grep --help 2>/dev/null)
- # Start collecting available options
- local -a grepopts
-
- # Add option to ignore binary files
- grepopts=("${grepopts[@]}" '-I')
-
# If the --exclude option is available, exclude some VCS files
if [[ $grephelp == *--exclude* ]] ; then
for exclude_file in .gitignore .gitmodules ; do
diff --git a/bash/bashrc.d/ls.bash b/bash/bashrc.d/ls.bash
index 0dedfdcc..255d6cd3 100644
--- a/bash/bashrc.d/ls.bash
+++ b/bash/bashrc.d/ls.bash
@@ -11,7 +11,7 @@ lsopts() {
# at least eight colors, add --color=auto to the options
local colors=$(tput colors)
if [[ $lshelp == *--color* ]] && ((colors >= 8)) ; then
- lsopts=("${lsopts[@]}" '--color=auto')
+ lsopts=("${lsopts[@]}" --color=auto)
fi
# Print the options as a single string, space-delimited
diff --git a/bash/bashrc.d/mysql.bash b/bash/bashrc.d/mysql.bash
index d04b189d..24317b24 100644
--- a/bash/bashrc.d/mysql.bash
+++ b/bash/bashrc.d/mysql.bash
@@ -30,9 +30,8 @@ _mysql() {
# Check directory exists and has at least one .cnf file
local dir="$HOME"/.mysql
if [[ ! -d $dir ]] || (
- declare -a files
shopt -s nullglob dotglob
- files=("$dir"/*.cnf)
+ declare -a files=("$dir"/*.cnf)
((! ${#files[@]}))
) ; then
COMPREPLY=()
@@ -40,8 +39,7 @@ _mysql() {
fi
# Return the names of the .cnf files sans prefix as completions
- local -a items
- items=("$dir"/*.cnf)
+ local -a items=("$dir"/*.cnf)
items=("${items[@]##*/}")
items=("${items[@]%%.cnf}")
COMPREPLY=( $(compgen -W "${items[*]}" -- "$word") )