2023-05-30 23:49:02 +02:00
|
|
|
function nvim_ve {
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -e $VIRTUAL_ENV && -f "$VIRTUAL_ENV/bin/activate" ]]; then
|
|
|
|
source "$VIRTUAL_ENV/bin/activate"
|
|
|
|
command nvim $@
|
|
|
|
deactivate
|
|
|
|
else
|
|
|
|
command nvim $@
|
|
|
|
fi
|
2023-05-30 23:49:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
alias nvim=nvim_ve
|
|
|
|
|
|
|
|
function ffb {
|
2024-02-19 15:54:50 +01:00
|
|
|
if ! [[ -f package.json ]]; then
|
|
|
|
echo "no package.json"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -f yarn.lock ]]; then
|
|
|
|
PACKAGE_MANAGER=yarn
|
|
|
|
else
|
|
|
|
PACKAGE_MANAGER=npm
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -n $(grep "react-scripts" package.json) ]]; then
|
|
|
|
BROWSER=none FORCE_COLOR=true "$PACKAGE_MANAGER" start | cat
|
|
|
|
fi
|
2023-05-30 23:49:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function afm {
|
2024-02-19 15:54:50 +01:00
|
|
|
RES=$(curl -s "https://$1/api/monitoring/requirements")
|
|
|
|
COUNT=$(echo "$RES" | grep -c $2)
|
|
|
|
if [[ $COUNT -ge 0 ]]; then
|
|
|
|
VER=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).version')
|
|
|
|
# OP=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).requirement?[0][0]')
|
|
|
|
# echo "$2""$(echo "$OP" | tr -d '"')""$(echo "$VER" | tr -d '"')"
|
|
|
|
echo "${2}==$(echo "$VER" | tr -d '"')"
|
|
|
|
fi
|
2023-05-30 23:49:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function nukepip {
|
2024-02-19 15:54:50 +01:00
|
|
|
pip uninstall $(pip freeze) -y
|
|
|
|
pip install -r $(pyenv root)/default-packages
|
2023-05-30 23:49:02 +02:00
|
|
|
}
|
2023-06-14 11:52:56 +02:00
|
|
|
|
|
|
|
function pyinit {
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -f .python-version ]]; then
|
|
|
|
echo "found .python-version, stopping"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
DIRNAME=$(basename "$PWD")
|
|
|
|
|
|
|
|
if [[ $(pyenv versions | grep -E "/${DIRNAME}$") ]]; then
|
|
|
|
echo "found existing version with this name, setting..."
|
|
|
|
pyenv local "$DIRNAME"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
echo "no python version provided, defaulting to $(pyenv version-name)"
|
|
|
|
VERSION=$(pyenv version-name)
|
|
|
|
else
|
|
|
|
VERSION=$1
|
|
|
|
fi
|
|
|
|
|
|
|
|
pyenv virtualenv "$VERSION" "$DIRNAME"
|
2023-06-14 11:52:56 +02:00
|
|
|
pyenv local "$DIRNAME"
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function lh {
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
PORT=8000
|
|
|
|
else
|
|
|
|
PORT=$1
|
|
|
|
fi
|
2023-06-14 11:52:56 +02:00
|
|
|
|
2024-02-19 15:54:50 +01:00
|
|
|
open "http://localhost:$PORT"
|
2023-06-14 11:52:56 +02:00
|
|
|
}
|
2023-06-16 17:23:38 +02:00
|
|
|
|
|
|
|
function dps {
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
docker ps --format table'{{ .ID }}\t{{ .Image }}\t{{ .Ports}}\t{{ .Names }}'
|
|
|
|
else
|
|
|
|
docker ps --format table'{{ .ID }}\t{{ .Image }}\t{{ .Ports}}\t{{ .Names }}' | grep $1
|
|
|
|
fi
|
2023-06-16 17:23:38 +02:00
|
|
|
}
|
|
|
|
|
2023-10-06 14:49:46 +02:00
|
|
|
function get_dump {
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
echo "provide ssh host"
|
|
|
|
return
|
|
|
|
fi
|
2023-10-06 14:49:46 +02:00
|
|
|
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -z $2 ]]; then
|
|
|
|
echo "provide dump destination"
|
|
|
|
return
|
|
|
|
fi
|
2023-10-06 14:49:46 +02:00
|
|
|
|
2024-02-19 15:54:50 +01:00
|
|
|
selected=$(ssh "$1" docker ps --format "{{.Names}}" | fzf)
|
2023-10-06 14:49:46 +02:00
|
|
|
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -z $selected ]]; then
|
|
|
|
return
|
|
|
|
fi
|
2023-10-06 14:49:46 +02:00
|
|
|
|
2024-02-19 15:54:50 +01:00
|
|
|
ssh "$1" docker exec "$selected" pg_dump -U db --format=c db >"$2$(date +'%Y-%m-%dT%H.%M.%S%z')"
|
2023-10-06 14:49:46 +02:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
function ggcompile {
|
2024-02-19 15:54:50 +01:00
|
|
|
find -L "$GGROOT" -mindepth 1 -maxdepth 5 -type d -name .git -prune \
|
|
|
|
-exec dirname {} \; >"$GGROOT/compiled"
|
2023-10-06 14:49:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function tssh {
|
2024-02-19 15:54:50 +01:00
|
|
|
if [[ -z $1 ]]; then
|
|
|
|
echo "provide ssh host"
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
|
|
|
|
ssh -t "$@" "command -v tmux && (tmux a || tmux new-session -s gorazd -c ~) || bash"
|
|
|
|
}
|
|
|
|
|
|
|
|
function ssh-menu {
|
|
|
|
selected=$(
|
|
|
|
grep 'Host .*' ~/.ssh/config \
|
|
|
|
| grep -v '*' \
|
|
|
|
| sed 's/Host \(.*\)/\1/' \
|
|
|
|
| fzf --cycle --bind 'tab:toggle-up,btab:toggle-down'
|
|
|
|
)
|
|
|
|
|
|
|
|
if [[ -z $selected ]]; then
|
|
|
|
return
|
|
|
|
fi
|
2023-10-06 14:49:46 +02:00
|
|
|
|
2024-02-19 15:54:50 +01:00
|
|
|
ssh "$selected"
|
2023-10-06 14:49:46 +02:00
|
|
|
}
|