1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192[ -n "$BASH" ] && is_bash=-f
there() {
# Checks the availability of an executable
command -v "$@" >/dev/null 2>&1
} && export $is_bash there
open_project() {
# search only dirs
search_loc=${1:-.}
cd "${search_loc}"
projdir=$(ls -d */.git | sed 's/.git$//g' | $FUZZER)
if [ -d "${projdir}" ]; then
cd "${projdir}"
fi
} && export $is_bash open_project
attach() {
command -v abduco >/dev/null || return
if [ $# -eq 0 ]; then
sesh_name=$(abduco -l | tail -n +2 | cut -f3 | $FUZZER)
test -z "$sesh_name" && return
abduco -a $sesh_name || abduco -c $sesh_name mtm;
else
abduco -a $1
fi
} && export $is_bash attach
# TODO make it non-interruptable
if ! there sl; then
sl() {
printf "You are a noob for typing '$1'\n"; sleep 5;
} && export $is_bash sl
fi
smartmake() {
if there fmake && there errorformat; then
fmake $* | errorformat
else
make
fi
} && export $is_bash smartmake
quickopen() {
if ! there "${FUZZER}"; then
printf '${FUZZER} not available\n'
return
fi
# TODO maybe add -type in the future TODO add $name
#if [ $# -gt 0 ]; then
# name="-name $@"
#fi
# 2>/dev/null
if [ -d .git ]; then
optional_files="$(git ls-files) |"
somethin="$(git ls-files | ${FUZZER})"
else
maxdepth=${1:-3} somethin="$(find . -maxdepth $maxdepth | ${FUZZER})"
fi
if [ -z "$somethin" ]; then
return;
elif [ -f "$somethin" ]; then
$EDITOR "$somethin"
elif [ -d "$somethin" ]; then
cd "$somethin"
else
printf '%s: is neither a file nor a directory\n' "$somethin"
return
fi
}
download() {
case $1 in
git@*|*.git|https://*.git) git clone $* ;;
*) curl -fLO $* ;; # TODO use wget if curl not available
esac
}
find_() {
find . -name "*$**"
}
vim_plug() {
VIM_PLUGINS_DIR="$XDG_DATA_HOME"/vim/pack/voom/opt \
VIM_DIR="$XDG_DATA_HOME"/vim voom $@
}
nvim_plug() {
VIM_PLUGINS_DIR="$XDG_DATA_HOME"/nvim/pack/voom/optj \
VIM_DIR="$XDG_DATA_HOME"/nvim voom $@
}