feat(zsh): add ssh-menu and run shmft

This commit is contained in:
Matej Janezic 2024-02-19 15:54:50 +01:00
parent a9fe95254a
commit d7f8b52c98
Signed by: janezicmatej
GPG Key ID: 4298E230ED37B2C0
2 changed files with 95 additions and 83 deletions

View File

@ -1,9 +1,8 @@
alias s="ssh"
alias z="exec zsh"
alias t="tmux a || tmux new-session -s $(whoami) -c ~"
alias n=nvim_ve
# alias vim=nvim_ve
alias ssh-hosts="grep -P \"^Host ([^*]+)$\" $HOME/.ssh/config | sed 's/Host //'"
alias s="ssh-menu"
# navigation
alias cdgit="cd $GGROOT"

View File

@ -1,6 +1,5 @@
function nvim_ve {
if [[ -e "$VIRTUAL_ENV" && -f "$VIRTUAL_ENV/bin/activate" ]]; then
if [[ -e $VIRTUAL_ENV && -f "$VIRTUAL_ENV/bin/activate" ]]; then
source "$VIRTUAL_ENV/bin/activate"
command nvim $@
deactivate
@ -35,11 +34,10 @@ function afm {
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 '"')"
echo "${2}==$(echo "$VER" | tr -d '"')"
fi
}
function nukepip {
pip uninstall $(pip freeze) -y
pip install -r $(pyenv root)/default-packages
@ -89,7 +87,6 @@ function dps {
fi
}
function get_dump {
if [[ -z $1 ]]; then
echo "provide ssh host"
@ -112,7 +109,8 @@ function get_dump {
}
function ggcompile {
find -L $GGROOT -mindepth 1 -maxdepth 5 -type d -name .git -prune | xargs -n 1 dirname > "$GGROOT/compiled"
find -L "$GGROOT" -mindepth 1 -maxdepth 5 -type d -name .git -prune \
-exec dirname {} \; >"$GGROOT/compiled"
}
function tssh {
@ -123,3 +121,18 @@ function tssh {
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
ssh "$selected"
}