done
}
caf() {
-
local file
find -L "$@" -type f -not \( -name .svn -prune -o -name .git -prune \
-o -name .hg -prune -o -name .editor-backups -prune \
-o -name .undo-tree-history -prune \) -printf '%h\0%d\0%p\n' | sort -t '\0' -n \
| awk -F '\0' '{print $3}' 2>/dev/null | while read -r file; do
- hr
- printf "%s\n" "$file"
- hr
- cat "$file"
+ hr "$file"
+ v "$file"
done
}
ccomp cat cf caf
# horizontal row. used to break up output
hr() {
- local blocks
- # 180 is long enough.
- blocks=██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
- printf "%s\n" "$(tput setaf 5 2>/dev/null ||:)${blocks:0:${COLUMNS:-180}}$(tput sgr0 2>/dev/null||:)"
+ local start end end_count arg
+ # 180 is long enough. 5 for start.
+ start=█████ end=█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████
+ end_count=$(( ${COLUMNS:-180} - 5 ))
+ arg="$*"
+ if [[ $arg ]]; then
+ end_count=$(( end_count - 2 - ${#arg} ))
+ start="$start $arg "
+ fi
+ if (( end_count >= 1 )); then
+ end=${end:0:$end_count}
+ else
+ end=
+ fi
+ printf "%s\n" "$(tput setaf 5 2>/dev/null ||:)$start$end$(tput sgr0 2>/dev/null||:)"
}
# highlight
hl() {
grep -P --binary-files=text "$@" ${HISTFILE:-~/.bash_history} | uniq || [[ $? == 1 ]];
}
+# remove lines from history matching $1
+#
# todo: id like to do maybe a daily or hourly cronjob to
# check that my history file size is increasing. Ive had it
# inexplicably truncated in the past.
fi
x=$(ps -eF)
# final grep is because some commands tend to have a lot of trailing spaces
- y=$(echo "$x" | grep -iP "$@" | grep -o '.*[^ ]') ||:
+ y=$(echo "$x" | sed -r 's,//[^[:space:]:@/]+:[^[:space:]:@/]+@,//REDACTED_URL_USER@PASS/,g' | grep -iP "$@" | grep -o '.*[^ ]') ||:
if [[ $y ]]; then
echo "$x" | head -n 1 || [[ $? == 141 ]]
echo "$y"
shellcheck -W 999 -x -e $others "$@" || return $?
}
-# sk on all modified files in current git repo
+# sk on all modified & new files in current git repo. must git add for new files.
skmodified() {
local f
- for f in $(i s | awk '$1 == "modified:" {print $2}'); do
+ for f in $(i s | awk '$1 == "modified:" {print $2}; $1 == "new" {print $3}'); do
if sk-p "$f"; then
sk $f ||:
fi
for n in $numbers
do
- _spark_echo -n ${ticks[$(( (((n-min)<<8)/f) ))]}
+ _spark_echo -n ${ticks[$(( ((n-min)<<8)/f ))]}
done
_spark_echo
}
if [[ $HISTFILE ]]; then
history -a # save history
+ if [[ -e $HOME/.iank-stream-on ]]; then
+ if [[ $HISTFILE == $HOME/.bh ]]; then
+ ps_char="HISTP "
+ fi
+ elif [[ $HISTFILE == /a/bin/data/stream_hist ]]; then
+ ps_char="HISTS "
+ fi
fi
ps_color="$term_purple"
- ps_char='\$'
+ ps_char="$ps_char"'\$'
if [[ ! -O . ]]; then # not owner
if [[ -w . ]]; then # writable
ps_color="$term_bold$term_red"
fi
jobs_char=
if [[ $(jobs -p) ]]; then
- jobs_char='j\j '
+ jobs_char="$(jobs -p)"'j\j '
fi
room=${rooms[i]}
while read -r n; do
v=$((v+n))
+ # shellcheck disable=SC2004 # false positive
roomv[$i]=$(( ${roomv[$i]} + n ))
done < <(printf "%s\n" "$out" | grep -Po "$room.*?current[^0-9]*[0-9]*" | grep -o '[0-9]*$' )
done
command dsh -c "$@"
}
+# cat or bat with color if we have it
+v() {
+ if type -t batcat >/dev/null; then
+ # note: another useful useful style is "header"
+ batcat --color always --style plain --theme Coldark-Cold -P "$@"
+ else
+ cat "$@"
+ fi
+}
+
# * stuff that makes sense to be at the end