103 lines
1.7 KiB
Plaintext
103 lines
1.7 KiB
Plaintext
#{- ~/.functions -}#
|
|
|
|
# Enables or disables kwm hotkeys
|
|
hotkeys()
|
|
{
|
|
case "$1" in
|
|
"on") kwmc config hotkeys on; echo "Hotkeys enabled." ;;
|
|
"off") kwmc config hotkeys off; echo "Hotkeys disabled." ;;
|
|
*) printf "hotkeys: usage: hotkeys {on|off}\n" ;;
|
|
esac
|
|
}
|
|
|
|
# Passes basic arithmetic to bc
|
|
maths()
|
|
{
|
|
bc -l <<< "scale=2; $*"
|
|
}
|
|
|
|
cat_with_newline()
|
|
{
|
|
\cat "$@" && echo
|
|
}
|
|
alias cat="cat_with_newline"
|
|
|
|
k_prompt()
|
|
{
|
|
set -x
|
|
if [ -z ${KUBE_PROMPT+x} ]; then
|
|
export KUBE_PROMPT=1
|
|
else
|
|
unset KUBE_PROMPT
|
|
fi
|
|
set +x
|
|
}
|
|
|
|
kube_prompt()
|
|
{
|
|
set -x
|
|
if ! [ -z ${KUBE_PROMPT+x} ]; then
|
|
context=$(\cat ${KUBECONFIG} \
|
|
| grep "current-context: " \
|
|
| sed "s/current-context: //")
|
|
echo {$context}
|
|
fi
|
|
set +x
|
|
}
|
|
|
|
g_prompt()
|
|
{
|
|
if ! [ -z ${GIT_PROMPT+x} ]; then
|
|
export GIT_PROMPT=1
|
|
else
|
|
unset GIT_PROMPT
|
|
fi
|
|
}
|
|
|
|
git_prompt()
|
|
{
|
|
if ! [ -z ${GIT_PROMPT+x} ]; then
|
|
# Determine if we are in a git repository
|
|
if git rev-parse --is-inside-work-tree &> /dev/null; then
|
|
branch=$(git rev-parse --abbrev-ref HEAD)
|
|
echo [$branch]
|
|
fi
|
|
fi
|
|
}
|
|
|
|
prompt_command_append() {
|
|
arg=${1}
|
|
PROMPT_COMMAND=${PROMPT_COMMAND:+"$PROMPT_COMMAND; "}"${arg}"
|
|
}
|
|
|
|
prompt_command_prepend() {
|
|
arg=${1}
|
|
PROMPT_COMMAND="${arg}"${PROMPT_COMMAND:+"; $PROMPT_COMMAND"}
|
|
}
|
|
|
|
blesh-activate()
|
|
{
|
|
BLESH_PATH=$HOME/.nix-profile/share/blesh/ble.sh
|
|
if [ -r $BLESH_PATH ]; then
|
|
[[ $- == *i* ]] && . $HOME/.nix-profile/share/blesh/ble.sh
|
|
[[ ! ${BLE_VERSION-} ]] || ble-attach
|
|
fi
|
|
}
|
|
|
|
blesh-available() {
|
|
BLESH_PATH=$HOME/.nix-profile/share/blesh/ble.sh
|
|
if [ -r $BLESH_PATH ]; then
|
|
return 0
|
|
else
|
|
return 1
|
|
fi
|
|
}
|
|
|
|
blesh-attached () {
|
|
if [ -z ${BLE_VERSION:+x} ]; then
|
|
return 1
|
|
else
|
|
return 0
|
|
fi
|
|
}
|