Compare commits
16 Commits
5de5edca67
...
master
Author | SHA1 | Date | |
---|---|---|---|
360afecb75
|
|||
5fb9b3618b
|
|||
41fb0c639a
|
|||
4b17d5db2d
|
|||
cf85fb6372
|
|||
475c183ff7
|
|||
f39f21b624
|
|||
afef09e9a8
|
|||
290ed36719
|
|||
5fbc0bca6b
|
|||
6120bd900f
|
|||
71fa00e26b
|
|||
1507b0c3c4
|
|||
9837828c72
|
|||
dbc860d89d
|
|||
5cc4dac594
|
14
.gitignore
vendored
14
.gitignore
vendored
@@ -21,7 +21,13 @@ zsh/*
|
|||||||
!zsh/scripts.zsh
|
!zsh/scripts.zsh
|
||||||
!zsh/aliases.zsh
|
!zsh/aliases.zsh
|
||||||
!zsh/completions/.keep
|
!zsh/completions/.keep
|
||||||
!zsh/.p10k.zsh
|
!zsh/ssh-menu
|
||||||
|
!zsh/get-dump
|
||||||
|
|
||||||
|
# starship
|
||||||
|
!starship
|
||||||
|
starship/*
|
||||||
|
!starship/config.toml
|
||||||
|
|
||||||
# tmux
|
# tmux
|
||||||
!tmux
|
!tmux
|
||||||
@@ -38,3 +44,9 @@ git/*
|
|||||||
!git/config
|
!git/config
|
||||||
!git/gitignore
|
!git/gitignore
|
||||||
!git/aflabs
|
!git/aflabs
|
||||||
|
|
||||||
|
# ghostty
|
||||||
|
!ghostty
|
||||||
|
ghostty/*
|
||||||
|
!ghostty/config
|
||||||
|
!ghostty/themes
|
||||||
|
@@ -75,6 +75,7 @@ history = 10000
|
|||||||
|
|
||||||
[window]
|
[window]
|
||||||
dynamic_title = true
|
dynamic_title = true
|
||||||
|
option_as_alt = "Both"
|
||||||
|
|
||||||
[window.dimensions]
|
[window.dimensions]
|
||||||
columns = 150
|
columns = 150
|
||||||
|
46
ghostty/config
Normal file
46
ghostty/config
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
# theme
|
||||||
|
# theme = light:gruvbox-material-soft-light,dark:gruvbox-material-soft-dark
|
||||||
|
theme = gruvbox-material-soft-dark
|
||||||
|
|
||||||
|
# cursor
|
||||||
|
cursor-style = block
|
||||||
|
cursor-style-blink = true
|
||||||
|
|
||||||
|
# mouse
|
||||||
|
mouse-hide-while-typing = true
|
||||||
|
|
||||||
|
# font stuff
|
||||||
|
font-family = JetBrainsMono Nerd Font
|
||||||
|
font-size = 15
|
||||||
|
font-thicken = true
|
||||||
|
bold-is-bright = true
|
||||||
|
|
||||||
|
# disable ligatures
|
||||||
|
font-feature=-calt
|
||||||
|
font-feature=-liga
|
||||||
|
font-feature=-dlig
|
||||||
|
|
||||||
|
# window
|
||||||
|
window-theme = dark
|
||||||
|
window-height = 36
|
||||||
|
window-width = 150
|
||||||
|
|
||||||
|
# macos send option as alt
|
||||||
|
macos-option-as-alt = true
|
||||||
|
|
||||||
|
# no warning full close
|
||||||
|
confirm-close-surface = false
|
||||||
|
# quit-after-last-window-closed = true
|
||||||
|
|
||||||
|
# keybinds
|
||||||
|
keybind = global:cmd+enter=new_window
|
||||||
|
|
||||||
|
# shell integrations for zsh
|
||||||
|
# https://ghostty.org/docs/features/shell-integration
|
||||||
|
shell-integration = zsh
|
||||||
|
|
||||||
|
# gtk
|
||||||
|
gtk-titlebar = false
|
||||||
|
|
||||||
|
# paste protection
|
||||||
|
clipboard-paste-protection = false
|
21
ghostty/themes/gruvbox-material-soft-dark
Normal file
21
ghostty/themes/gruvbox-material-soft-dark
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
palette = 0=252423
|
||||||
|
palette = 1=#ea6962
|
||||||
|
palette = 2=#a9b665
|
||||||
|
palette = 3=#d8a657
|
||||||
|
palette = 4=#7daea3
|
||||||
|
palette = 5=#d3869b
|
||||||
|
palette = 6=#89b482
|
||||||
|
palette = 7=#d4be98
|
||||||
|
palette = 8=#32302f
|
||||||
|
palette = 9=#ea6962
|
||||||
|
palette = 10=#a9b665
|
||||||
|
palette = 11=#d8a657
|
||||||
|
palette = 12=#7daea3
|
||||||
|
palette = 13=#d3869b
|
||||||
|
palette = 14=#89b482
|
||||||
|
palette = 15=#d4be98
|
||||||
|
background = #32302f
|
||||||
|
foreground = #d4be98
|
||||||
|
cursor-color = #d4be98
|
||||||
|
selection-background = #45403d
|
||||||
|
selection-foreground = #d4be98
|
21
ghostty/themes/gruvbox-material-soft-light
Normal file
21
ghostty/themes/gruvbox-material-soft-light
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
palette = 0=#ebdbb2
|
||||||
|
palette = 1=#c14a4a
|
||||||
|
palette = 2=#6c782e
|
||||||
|
palette = 3=#b47109
|
||||||
|
palette = 4=#45707a
|
||||||
|
palette = 5=#945e80
|
||||||
|
palette = 6=#4c7a5d
|
||||||
|
palette = 7=#654735
|
||||||
|
palette = 8=#f3eac7
|
||||||
|
palette = 9=#c14a4a
|
||||||
|
palette = 10=#6c782e
|
||||||
|
palette = 11=#b47109
|
||||||
|
palette = 12=#45707a
|
||||||
|
palette = 13=#945e80
|
||||||
|
palette = 14=#4c7a5d
|
||||||
|
palette = 15=#654735
|
||||||
|
background = #f2e5bc
|
||||||
|
foreground = #654735
|
||||||
|
cursor-color = #654735
|
||||||
|
selection-background = #ebdbb2
|
||||||
|
selection-foreground = #654735
|
@@ -14,3 +14,5 @@
|
|||||||
|
|
||||||
[init]
|
[init]
|
||||||
defaultBranch = main
|
defaultBranch = main
|
||||||
|
[alias]
|
||||||
|
blame = "!f() { [ -f .git-blame-ignore-revs ] && git blame --ignore-revs-file .git-blame-ignore-revs \"$@\" || git blame \"$@\"; }; f"
|
||||||
|
2
nvim
2
nvim
Submodule nvim updated: b2fe474605...d97244ca10
58
starship/config.toml
Normal file
58
starship/config.toml
Normal file
@@ -0,0 +1,58 @@
|
|||||||
|
add_newline = false
|
||||||
|
|
||||||
|
format = """\
|
||||||
|
$hostname\
|
||||||
|
[$directory](cyan)\
|
||||||
|
$git_branch\
|
||||||
|
$git_commit\
|
||||||
|
$git_state\
|
||||||
|
$git_status\
|
||||||
|
$character\
|
||||||
|
"""
|
||||||
|
|
||||||
|
right_format = """\
|
||||||
|
$golang\
|
||||||
|
$lua\
|
||||||
|
$nodejs\
|
||||||
|
$python\
|
||||||
|
$rust\
|
||||||
|
$cmd_duration\
|
||||||
|
"""
|
||||||
|
|
||||||
|
[character]
|
||||||
|
success_symbol = '[>](bold green)'
|
||||||
|
error_symbol = '[>](bold red)'
|
||||||
|
|
||||||
|
[directory]
|
||||||
|
truncation_length = 1
|
||||||
|
truncate_to_repo = false
|
||||||
|
fish_style_pwd_dir_length = 1
|
||||||
|
|
||||||
|
[git_commit]
|
||||||
|
tag_symbol = ''
|
||||||
|
|
||||||
|
[git_branch]
|
||||||
|
symbol = ''
|
||||||
|
|
||||||
|
[git_status]
|
||||||
|
format = '[$all_status$ahead_behind]($style)'
|
||||||
|
ahead = '[↑${count}](green) '
|
||||||
|
diverged = '[↑${ahead_count}↓${behind_count}](red) '
|
||||||
|
behind = '[↓${count}](green) '
|
||||||
|
modified = '[!${count}](yellow) '
|
||||||
|
untracked = '[?${count}](blue) '
|
||||||
|
staged = '[+${count}](yellow) '
|
||||||
|
stashed = '[*${count}](green) '
|
||||||
|
deleted = '[x${count}](red) '
|
||||||
|
renamed = '[r${count}](yellow) '
|
||||||
|
|
||||||
|
[python]
|
||||||
|
format = 'via [${symbol}${pyenv_prefix}(${version} )(\($virtualenv\) )]($style)'
|
||||||
|
python_binary = 'python'
|
||||||
|
pyenv_version_name = false
|
||||||
|
detect_files = [ '.python-version' ]
|
||||||
|
|
||||||
|
[hostname]
|
||||||
|
ssh_only = false
|
||||||
|
style = 'bold yellow'
|
||||||
|
format = '[$hostname]($style) on '
|
@@ -3,18 +3,27 @@
|
|||||||
if [[ $# -eq 1 ]]; then
|
if [[ $# -eq 1 ]]; then
|
||||||
selected=$1
|
selected=$1
|
||||||
else
|
else
|
||||||
if ! [[ -f "$GGROOT/compiled" ]]; then
|
selected=$(ggman exec pwd 2>&1 >/dev/null \
|
||||||
find -L $GGROOT -mindepth 1 -maxdepth 5 -type d -name .git -prune | xargs -n 1 dirname > "$GGROOT/compiled"
|
| fzf --cycle \
|
||||||
fi
|
--bind 'tab:toggle-up,btab:toggle-down' \
|
||||||
selected=$(cat "$GGROOT/compiled" | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down')
|
--header "Navigate with ARROW KEYS or TAB/S-TAB. Select with ENTER." \
|
||||||
|
--border "double" \
|
||||||
|
--border-label "tmux-sessionizer" \
|
||||||
|
--ansi \
|
||||||
|
--highlight-line \
|
||||||
|
)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -z $selected ]]; then
|
if [[ -z $selected ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
path=$selected
|
||||||
|
while [[ "$path" != "" && ! -e "$path/.sessionizer" ]]; do
|
||||||
|
path=${path%/*}
|
||||||
|
done
|
||||||
|
|
||||||
selected_name=$(basename "$selected" | tr . _)
|
selected_name="$(cat $path/.sessionizer)_$(basename $selected | tr . _ | head -c 10)_$(echo $selected | shasum -a 256 | head -c 4)"
|
||||||
tmux_running=$(pgrep tmux)
|
tmux_running=$(pgrep tmux)
|
||||||
|
|
||||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||||
|
@@ -1,25 +1,77 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
if [[ $# -eq 1 ]]; then
|
function _preview {
|
||||||
|
file=$1; shift
|
||||||
|
host=$1; shift
|
||||||
|
|
||||||
|
j=$(cat $file \
|
||||||
|
| jc --ssh-conf \
|
||||||
|
| jq -r ".[] \
|
||||||
|
| select(.host == \"$host\") \
|
||||||
|
| .jumps = (if (.proxyjump | type == \"array\" and length > 0) then (.proxyjump | join(\",\")) else \"null\" end)" \
|
||||||
|
)
|
||||||
|
|
||||||
|
user=$(jq -r '.user' <<<$j)
|
||||||
|
port=$(jq -r '.port' <<<$j)
|
||||||
|
hostname=$(jq -r '.hostname' <<<$j)
|
||||||
|
jumps=$(jq -r '.jumps' <<<$j)
|
||||||
|
|
||||||
|
|
||||||
|
echo "$(cat <<EOF
|
||||||
|
User $user
|
||||||
|
HostName $hostname\
|
||||||
|
$([[ $port != "null" ]] && echo -e "\nPort $port")\
|
||||||
|
$([[ $jumps != "null" ]] && echo -e "\nProxyJump $jumps")
|
||||||
|
|
||||||
|
command:
|
||||||
|
ssh $user@$hostname$([[ $port != "null" ]] && echo -n " -p $port")$([[ $jumps != "null" ]] && echo -n " -J $jumps")
|
||||||
|
EOF)"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
host $hostname
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
ping -c 1 -W 1 $hostname &>/dev/null \
|
||||||
|
&& echo "Host is reachable!" \
|
||||||
|
|| echo "Host is not reachable!"
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f _preview
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
if [[ $# -eq 1 ]]; then
|
||||||
selected=$1
|
selected=$1
|
||||||
else
|
else
|
||||||
selected="$(grep 'Host .*' ~/.ssh/config | grep -v '*' | sed 's/Host \(.*\)/\1/' | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down')"
|
selected="$(rg -N --no-heading 'Host .*' ~/.ssh \
|
||||||
fi
|
| sed 's/Host \(.*\)/\1/' \
|
||||||
|
| SHELL=$(which bash) fzf --cycle \
|
||||||
|
--bind 'tab:toggle-up,btab:toggle-down' \
|
||||||
|
--delimiter ':' \
|
||||||
|
--with-nth 2 \
|
||||||
|
--preview "_preview {1} {2}" \
|
||||||
|
| cut -d ":" -f2
|
||||||
|
)"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -z $selected ]]; then
|
if [[ -z $selected ]]; then
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
selected_name="ssh_$selected"
|
selected_name="ssh_$selected"
|
||||||
tmux_running=$(pgrep tmux)
|
tmux_running=$(pgrep tmux)
|
||||||
|
|
||||||
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
if [[ -z $TMUX ]] && [[ -z $tmux_running ]]; then
|
||||||
tmux new-session -s $selected_name -c $selected ssh "$selected"
|
tmux new-session -s $selected_name -c $selected ssh "$selected"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! tmux has-session -t=$selected_name 2> /dev/null; then
|
if ! tmux has-session -t=$selected_name 2> /dev/null; then
|
||||||
tmux new-session -ds $selected_name -c $selected ssh "$selected"
|
tmux new-session -ds $selected_name -c $selected ssh "$selected"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmux switch-client -t $selected_name
|
tmux switch-client -t $selected_name
|
||||||
|
}
|
||||||
|
|
||||||
|
main "$@"
|
||||||
|
1697
zsh/.p10k.zsh
1697
zsh/.p10k.zsh
File diff suppressed because it is too large
Load Diff
@@ -7,9 +7,6 @@ getantidote/use-omz # handle OMZ dependencies
|
|||||||
ohmyzsh/ohmyzsh path:lib # load OMZ's library
|
ohmyzsh/ohmyzsh path:lib # load OMZ's library
|
||||||
ohmyzsh/ohmyzsh path:plugins/git
|
ohmyzsh/ohmyzsh path:plugins/git
|
||||||
|
|
||||||
# theme
|
|
||||||
romkatv/powerlevel10k
|
|
||||||
|
|
||||||
# popular fish-like plugins
|
# popular fish-like plugins
|
||||||
zsh-users/zsh-autosuggestions
|
zsh-users/zsh-autosuggestions
|
||||||
|
|
||||||
|
10
zsh/.zshenv
10
zsh/.zshenv
@@ -4,6 +4,9 @@ export XDG_CACHE_HOME="$HOME/.cache"
|
|||||||
export XDG_DATA_HOME="$HOME/.local/share"
|
export XDG_DATA_HOME="$HOME/.local/share"
|
||||||
export XDG_STATE_HOME="$HOME/.local/state"
|
export XDG_STATE_HOME="$HOME/.local/state"
|
||||||
|
|
||||||
|
# ~/.local/bin
|
||||||
|
export PATH="$HOME/.local/bin:$PATH"
|
||||||
|
|
||||||
# brew sbin
|
# brew sbin
|
||||||
export PATH="/opt/homebrew/sbin:$PATH"
|
export PATH="/opt/homebrew/sbin:$PATH"
|
||||||
|
|
||||||
@@ -34,6 +37,10 @@ export PATH="$XDG_DATA_HOME/neovim/bin:$PATH"
|
|||||||
export PYENV_ROOT="$XDG_DATA_HOME/.pyenv"
|
export PYENV_ROOT="$XDG_DATA_HOME/.pyenv"
|
||||||
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
|
command -v pyenv >/dev/null || export PATH="$PYENV_ROOT/bin:$PATH"
|
||||||
|
|
||||||
|
# pyenv-virtualenv
|
||||||
|
# leave python promt to starship
|
||||||
|
export PYENV_VIRTUALENV_DISABLE_PROMPT=1
|
||||||
|
|
||||||
# poetry
|
# poetry
|
||||||
export POETRY_HOME="$XDG_DATA_HOME/poetry"
|
export POETRY_HOME="$XDG_DATA_HOME/poetry"
|
||||||
command -v poetry >/dev/null || export PATH="$POETRY_HOME/bin:$PATH"
|
command -v poetry >/dev/null || export PATH="$POETRY_HOME/bin:$PATH"
|
||||||
@@ -47,3 +54,6 @@ export USER_GID=$(id -g)
|
|||||||
|
|
||||||
# name
|
# name
|
||||||
export NAME="Matej Janežič"
|
export NAME="Matej Janežič"
|
||||||
|
|
||||||
|
# starship nest config into a folder, default is ~/.config/startship.toml
|
||||||
|
export STARSHIP_CONFIG="$XDG_CONFIG_HOME/starship/config.toml"
|
||||||
|
16
zsh/.zshrc
16
zsh/.zshrc
@@ -2,16 +2,11 @@
|
|||||||
export HISTFILE="$XDG_STATE_HOME/zsh/history"
|
export HISTFILE="$XDG_STATE_HOME/zsh/history"
|
||||||
export HISTSIZE=100
|
export HISTSIZE=100
|
||||||
|
|
||||||
# Enable Powerlevel10k instant prompt. Should stay close to the top of ~/.config/zsh/.zshrc.
|
|
||||||
# Initialization code that may require console input (password prompts, [y/n]
|
|
||||||
# confirmations, etc.) must go above this block; everything else may go below.
|
|
||||||
if [[ -r "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh" ]]; then
|
|
||||||
source "${XDG_CACHE_HOME:-$HOME/.cache}/p10k-instant-prompt-${(%):-%n}.zsh"
|
|
||||||
fi
|
|
||||||
|
|
||||||
## pre plugin load
|
## pre plugin load
|
||||||
# nvm
|
# nvm
|
||||||
export NVM_COMPLETION=true
|
export NVM_COMPLETION=true
|
||||||
|
# zsh autosugestions
|
||||||
|
export ZSH_AUTOSUGGEST_HIGHLIGHT_STYLE="fg=#ffffff,bg=cyan,bold,underline"
|
||||||
|
|
||||||
# source antidote
|
# source antidote
|
||||||
source $ZDOTDIR/.antidote/antidote.zsh
|
source $ZDOTDIR/.antidote/antidote.zsh
|
||||||
@@ -20,8 +15,8 @@ antidote load
|
|||||||
unsetopt autocd
|
unsetopt autocd
|
||||||
|
|
||||||
# pyenv
|
# pyenv
|
||||||
eval "$(pyenv init -)"
|
eval "$(pyenv init - zsh)"
|
||||||
eval "$(pyenv virtualenv-init -)"
|
eval "$(pyenv virtualenv-init - zsh)"
|
||||||
|
|
||||||
# ggman
|
# ggman
|
||||||
eval "$(ggman shellrc)"
|
eval "$(ggman shellrc)"
|
||||||
@@ -39,5 +34,4 @@ zstyle ':completion:*' cache-path $XDG_CACHE_HOME/zsh/zcompcache
|
|||||||
# opam configuration
|
# opam configuration
|
||||||
# [[ ! -r /Users/janezicmatej/.opam/opam-init/init.zsh ]] || source /Users/janezicmatej/.opam/opam-init/init.zsh > /dev/null 2> /dev/null
|
# [[ ! -r /Users/janezicmatej/.opam/opam-init/init.zsh ]] || source /Users/janezicmatej/.opam/opam-init/init.zsh > /dev/null 2> /dev/null
|
||||||
|
|
||||||
# To customize prompt, run `p10k configure` or edit ~/.config/zsh/.p10k.zsh.
|
eval "$(starship init zsh)"
|
||||||
[[ ! -f ~/.config/zsh/.p10k.zsh ]] || source ~/.config/zsh/.p10k.zsh
|
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
alias z="exec zsh"
|
alias z="exec zsh"
|
||||||
alias t="tmux a || tmux new-session -s $(whoami) -c ~"
|
alias t="tmux a || ~/.config/tmux/tmux-sessionizer ~"
|
||||||
alias n=nvim_ve
|
alias n=nvim_ve
|
||||||
# alias vim=nvim_ve
|
# alias vim=nvim_ve
|
||||||
alias s="ssh-menu"
|
alias s="ssh-menu"
|
||||||
@@ -22,3 +22,9 @@ alias ci="glab ci list"
|
|||||||
alias bm=batman
|
alias bm=batman
|
||||||
alias grow="~/.local/bin/cbonsai -liWC -M 15 -t 2 -w 60 -s $(date +%s)"
|
alias grow="~/.local/bin/cbonsai -liWC -M 15 -t 2 -w 60 -s $(date +%s)"
|
||||||
alias clean_ds_store='find . -name ".DS_Store" -type f -delete -print'
|
alias clean_ds_store='find . -name ".DS_Store" -type f -delete -print'
|
||||||
|
|
||||||
|
# ruff
|
||||||
|
alias ruffme="ruff format && ruff check --fix"
|
||||||
|
|
||||||
|
# clipboard
|
||||||
|
alias xcp="xclip -selection c"
|
||||||
|
51
zsh/get-dump
Executable file
51
zsh/get-dump
Executable file
@@ -0,0 +1,51 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function get-dump {
|
||||||
|
if [[ -z $1 ]]; then
|
||||||
|
host="$(rg -N --no-heading 'Host .*' ~/.ssh \
|
||||||
|
| sed 's/Host \(.*\)/\1/' \
|
||||||
|
| fzf --cycle \
|
||||||
|
--bind 'tab:toggle-up,btab:toggle-down' \
|
||||||
|
--delimiter ':' \
|
||||||
|
--with-nth 2 \
|
||||||
|
--header "Navigate with ARROW KEYS or TAB/S-TAB. Select with ENTER." \
|
||||||
|
--border "double" \
|
||||||
|
--border-label "get-dump" \
|
||||||
|
--ansi \
|
||||||
|
--highlight-line \
|
||||||
|
| cut -d ":" -f2
|
||||||
|
)"
|
||||||
|
if [[ -z $host ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
host=$1
|
||||||
|
fi
|
||||||
|
|
||||||
|
selected=$(ssh "$host" docker ps --format "{{.Names}}" \
|
||||||
|
| fzf --cycle \
|
||||||
|
--bind 'tab:toggle-up,btab:toggle-down' \
|
||||||
|
--header "Navigate with ARROW KEYS or TAB/S-TAB. Select with ENTER." \
|
||||||
|
--border "double" \
|
||||||
|
--border-label "get-dump" \
|
||||||
|
--ansi \
|
||||||
|
--highlight-line \
|
||||||
|
)
|
||||||
|
|
||||||
|
if [[ -z $selected ]]; then
|
||||||
|
echo "not provided"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
if ! [[ -d "./dumps" ]]; then
|
||||||
|
mkdir "./dumps"
|
||||||
|
fi
|
||||||
|
|
||||||
|
location="./dumps/${host}_${selected}_$(date +'%s')"
|
||||||
|
|
||||||
|
echo "dumping to $location"
|
||||||
|
|
||||||
|
ssh "$host" docker exec "$selected" pg_dump -U db --format=c db >"$location"
|
||||||
|
}
|
||||||
|
|
||||||
|
get-dump "$@"
|
@@ -10,23 +10,6 @@ function nvim_ve {
|
|||||||
|
|
||||||
alias nvim=nvim_ve
|
alias nvim=nvim_ve
|
||||||
|
|
||||||
function ffb {
|
|
||||||
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
|
|
||||||
}
|
|
||||||
|
|
||||||
function afm {
|
function afm {
|
||||||
RES=$(curl -s "https://$1/api/monitoring/requirements")
|
RES=$(curl -s "https://$1/api/monitoring/requirements")
|
||||||
COUNT=$(echo "$RES" | grep -c $2)
|
COUNT=$(echo "$RES" | grep -c $2)
|
||||||
@@ -71,7 +54,7 @@ function pyinit {
|
|||||||
|
|
||||||
function lh {
|
function lh {
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
PORT=8000
|
PORT=7999
|
||||||
else
|
else
|
||||||
PORT=$1
|
PORT=$1
|
||||||
fi
|
fi
|
||||||
@@ -87,32 +70,6 @@ function dps {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_dump {
|
|
||||||
if [[ -z $1 ]]; then
|
|
||||||
echo "provide ssh host"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ -z $2 ]]; then
|
|
||||||
echo "provide dump destination"
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
selected=$(ssh "$1" docker ps --format "{{.Names}}" | fzf)
|
|
||||||
|
|
||||||
if [[ -z $selected ]]; then
|
|
||||||
return
|
|
||||||
fi
|
|
||||||
|
|
||||||
ssh "$1" docker exec "$selected" pg_dump -U db --format=c db >"$2$(date +'%Y-%m-%dT%H.%M.%S%z')"
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
function ggcompile {
|
|
||||||
find -L "$GGROOT" -mindepth 1 -maxdepth 5 -type d -name .git -prune \
|
|
||||||
-exec dirname {} \; >"$GGROOT/compiled"
|
|
||||||
}
|
|
||||||
|
|
||||||
function tssh {
|
function tssh {
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
echo "provide ssh host"
|
echo "provide ssh host"
|
||||||
@@ -122,17 +79,3 @@ function tssh {
|
|||||||
ssh -t "$@" "command -v tmux && (tmux a || tmux new-session -s gorazd -c ~) || bash"
|
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"
|
|
||||||
}
|
|
||||||
|
75
zsh/ssh-menu
Executable file
75
zsh/ssh-menu
Executable file
@@ -0,0 +1,75 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
function _ssh_menu_preview {
|
||||||
|
file=$1; shift
|
||||||
|
host=$1; shift
|
||||||
|
|
||||||
|
j=$(cat $file \
|
||||||
|
| jc --ssh-conf \
|
||||||
|
| jq -r ".[] \
|
||||||
|
| select(.host == \"$host\") \
|
||||||
|
| .jumps = (\
|
||||||
|
if (.proxyjump | type == \"array\" and length > 0) then \
|
||||||
|
(.proxyjump | join(\",\")) \
|
||||||
|
else \
|
||||||
|
\"null\" \
|
||||||
|
end \
|
||||||
|
)" \
|
||||||
|
)
|
||||||
|
|
||||||
|
user=$(jq -r '.user' <<<$j)
|
||||||
|
port=$(jq -r '.port' <<<$j)
|
||||||
|
hostname=$(jq -r '.hostname' <<<$j)
|
||||||
|
jumps=$(jq -r '.jumps' <<<$j)
|
||||||
|
|
||||||
|
|
||||||
|
echo "$(cat <<EOF
|
||||||
|
User $user
|
||||||
|
HostName $hostname\
|
||||||
|
$([[ $port != "null" ]] && echo -e "\nPort $port")\
|
||||||
|
$([[ $jumps != "null" ]] && echo -e "\nProxyJump $jumps")
|
||||||
|
|
||||||
|
command:
|
||||||
|
ssh $user@$hostname$([[ $port != "null" ]] && echo -n " -p $port")$([[ $jumps != "null" ]] && echo -n " -J $jumps")
|
||||||
|
EOF
|
||||||
|
)"
|
||||||
|
|
||||||
|
echo ""
|
||||||
|
|
||||||
|
if command -v host 2>&1 >/dev/null; then
|
||||||
|
host $hostname
|
||||||
|
echo ""
|
||||||
|
fi
|
||||||
|
|
||||||
|
ping -c 1 -W 1 $hostname &>/dev/null \
|
||||||
|
&& echo "Host is reachable!" \
|
||||||
|
|| echo "Host is not reachable!"
|
||||||
|
}
|
||||||
|
|
||||||
|
export -f _ssh_menu_preview
|
||||||
|
|
||||||
|
function ssh-menu {
|
||||||
|
selected="$(rg -N --no-heading 'Host .*' ~/.ssh \
|
||||||
|
| sed 's/Host \(.*\)/\1/' \
|
||||||
|
| SHELL=$(which bash) fzf --cycle \
|
||||||
|
--bind 'tab:toggle-up,btab:toggle-down' \
|
||||||
|
--delimiter ':' \
|
||||||
|
--with-nth 2 \
|
||||||
|
--preview "_ssh_menu_preview {1} {2}" \
|
||||||
|
--preview-label "ssh config info" \
|
||||||
|
--header "Navigate with ARROW KEYS or TAB/S-TAB. Select with ENTER." \
|
||||||
|
--border "double" \
|
||||||
|
--border-label "ssh-menu" \
|
||||||
|
--ansi \
|
||||||
|
--highlight-line \
|
||||||
|
| cut -d ":" -f2
|
||||||
|
)"
|
||||||
|
|
||||||
|
if [[ -z $selected ]]; then
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
|
ssh "$selected"
|
||||||
|
}
|
||||||
|
|
||||||
|
ssh-menu
|
Reference in New Issue
Block a user