export SL_INFO_DIR=/p/sshinfo
+
# * include files
if [[ -s $bashrc_dir/path-add-function ]]; then
### begin FSF section ###
+# use for temporary functions
+y() {
+ m "${@//spring/fall}"
+}
+h() {
+ e "${@//spring/fall}"
+}
+
+
# Comments before functions are meant to be good useful
# documentation. If they fail at that, please improve them or send Ian a
# note.
prof() {
command prof &>/dev/null &
}
-
-
+# self chat
+sc() {
+ while read -r l; do
+ printf '\033[1A\033[K'; printf "%s\n" "$l"| ts "%F %T" | tee -a /p/self-chat.log
+ done
+}
nmt() {
# cant use s because sudo -i doesnt work for passwordless sudo command
c "$(mktemp -d)"
pkg=$1
# shellcheck disable=SC2012
- cached=$(ls -t /var/cache/apt/archives/$pkg* | tail -n1 2>/dev/null) ||:
+ cached=$(ls -t /var/cache/apt/archives/${pkg}_* | tail -n1 2>/dev/null) ||:
if [[ $cached ]]; then
- cp $cached .
+ m cp $cached .
else
- aptitude download $pkg || return 1
+ m aptitude download $pkg || return 1
fi
tmp=(*); f=${tmp[0]} # only 1 expected
- ex $f
- rm -f $f
+ m ex $f
+ m rm -f $f
}
# pgrep and kill
fi
}
+# make vim work with my light colortheme terminal.
+vim() {
+ if [[ -e ~/.vimrc ]]; then
+ command vim "$@"
+ else
+ command vim -c ':colorscheme peachpuff' "$@"
+ fi
+}
+
+# ls count. usage: pass a directory, get the number of files.
+# https://unix.stackexchange.com/questions/90106/whats-the-most-resource-efficient-way-to-count-how-many-files-are-in-a-director
+lsc() {
+ ls -Uq "$@"|wc -l
+}
+
+# run then notify. close notification after the next prompt.
+rn() {
+ "$@"
+ dunstify -u critical "$*"
+ _psrun=(dunstctl close-all)
+}
+n() {
+ dunstify -u critical n
+}
+
+catnew() {
+ local dir file
+ dir="$1"
+ inotifywait -m "$dir" -e create -e moved_to | while read -r _ _ file; do
+ hr
+ cat "$dir/$file"
+ done
+}
+# cat mail
+cm() {
+ catnew /m/md/$1/new
+}
+
+
# * misc stuff
if [[ $(jobs -p) ]]; then
jobs_char='j\j '
fi
+
+
+ # allow a function to specify a command to run after we run the next
+ # command. Use case: a function makes a persistent notification. If
+ # we happen to be using that terminal, we can just keep working by
+ # entering our next command, even a noop in order to dismiss the
+ # notification, instead of having to explicitly dismiss it.
+ if [[ ${_psrun[@]} ]]; then
+ if (( _psrun_count >= 1 )); then
+
+ "${_psrun[@]}" ||:
+ _psrun_count=0
+ unset _psrun
+ else
+ _psrun_count=$(( _psrun_count + 1 ))
+ fi
+ else
+ _psrun_count=0
+ fi
+
# We could test if sudo is active with sudo -nv
# but then we get an email and log of lots of failed sudo commands.
# We could turn those off, but seems better not to.
fi
PS1="${PS1%"${PS1#*[wW]}"} $jobs_char$psudo\[$ps_color\]$ps_char\[$term_nocolor\] "
+ # copy of what is automatically added by guix.
+ # adds [env] to PS1 if GUIX_ENVIRONMENT is set and PS1 contains '$';
+ if [ -n "$GUIX_ENVIRONMENT" ]; then
+ if [[ $PS1 =~ (.*)"\\$" ]]; then
+ PS1="${BASH_REMATCH[1]} [env]\\\$ "
+ fi
+ fi
+
+
# set titlebar. instead, using more advanced
# titelbar below
#echo -ne "$_title_escape $HOSTNAME ${PWD/#$HOME/~} \007"