Compare commits
	
		
			5 Commits
		
	
	
		
			a1b422e29e
			...
			781edd5bf2
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						
						
							
						
						781edd5bf2
	
				 | 
					
					
						|||
| 
						
						
							
						
						90c71a0316
	
				 | 
					
					
						|||
| 
						
						
							
						
						d7f8b52c98
	
				 | 
					
					
						|||
| 
						
						
							
						
						a9fe95254a
	
				 | 
					
					
						|||
| 
						
						
							
						
						0cadba2ad4
	
				 | 
					
					
						
							
								
								
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										1
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@@ -26,6 +26,7 @@ zsh/*
 | 
				
			|||||||
!tmux
 | 
					!tmux
 | 
				
			||||||
tmux/*
 | 
					tmux/*
 | 
				
			||||||
!tmux/tmux.conf
 | 
					!tmux/tmux.conf
 | 
				
			||||||
 | 
					!tmux/tmux-new-project
 | 
				
			||||||
!tmux/tmux-sessionizer
 | 
					!tmux/tmux-sessionizer
 | 
				
			||||||
!tmux/tmux-ggclone
 | 
					!tmux/tmux-ggclone
 | 
				
			||||||
!tmux/tmux-ssher
 | 
					!tmux/tmux-ssher
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,8 +5,6 @@
 | 
				
			|||||||
	autocrlf = input
 | 
						autocrlf = input
 | 
				
			||||||
	excludesfile = ~/.config/git/gitignore
 | 
						excludesfile = ~/.config/git/gitignore
 | 
				
			||||||
	editor = nvim
 | 
						editor = nvim
 | 
				
			||||||
[init]
 | 
					 | 
				
			||||||
	defaultBranch = master
 | 
					 | 
				
			||||||
[include]
 | 
					[include]
 | 
				
			||||||
	path = ~/.config/git/alias
 | 
						path = ~/.config/git/alias
 | 
				
			||||||
[include]
 | 
					[include]
 | 
				
			||||||
@@ -14,3 +12,5 @@
 | 
				
			|||||||
[includeIf "gitdir:~/Desktop/git/git.aflabs.org/"]
 | 
					[includeIf "gitdir:~/Desktop/git/git.aflabs.org/"]
 | 
				
			||||||
	path = ~/.config/git/aflabs
 | 
						path = ~/.config/git/aflabs
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					[init]
 | 
				
			||||||
 | 
						defaultBranch = main
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										2
									
								
								nvim
									
									
									
									
									
								
							
							
								
								
								
								
								
							
						
						
									
										2
									
								
								nvim
									
									
									
									
									
								
							 Submodule nvim updated: b087eaa1ef...b2fe474605
									
								
							@@ -1,5 +1,7 @@
 | 
				
			|||||||
#!/usr/bin/env bash
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source "$XDG_CONFIG_HOME/zsh/scripts.zsh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if [[ $# -eq 1 ]]; then
 | 
					if [[ $# -eq 1 ]]; then
 | 
				
			||||||
    selected=$1
 | 
					    selected=$1
 | 
				
			||||||
else
 | 
					else
 | 
				
			||||||
@@ -11,5 +13,4 @@ if [[ -z $selected ]]; then
 | 
				
			|||||||
fi
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ggman clone "$selected"
 | 
					ggman clone "$selected"
 | 
				
			||||||
find -L $GGROOT -mindepth 1 -maxdepth 5 -type d -name .git -prune | xargs -n 1 dirname > "$GGROOT/compiled"
 | 
					ggcompile
 | 
				
			||||||
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										50
									
								
								tmux/tmux-new-project
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										50
									
								
								tmux/tmux-new-project
									
									
									
									
									
										Executable file
									
								
							@@ -0,0 +1,50 @@
 | 
				
			|||||||
 | 
					#!/usr/bin/env bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ -z ${NAME:+x} ]]; then
 | 
				
			||||||
 | 
					    echo "missing name"
 | 
				
			||||||
 | 
					    sleep 2
 | 
				
			||||||
 | 
					    exit 1
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					source "$XDG_CONFIG_HOME/zsh/scripts.zsh"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					read -p "name: " project_name
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ -z $project_name ]]; then
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if [[ -d "$GGROOT/no-remote/$project_name" ]]; then
 | 
				
			||||||
 | 
					    exit 0
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					project="$GGROOT/no-remote/$project_name"
 | 
				
			||||||
 | 
					git init $project
 | 
				
			||||||
 | 
					echo "# $project_name" >>"$project/README.md"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					gitignore_template=$(
 | 
				
			||||||
 | 
					    find "$GGROOT"/github.com/github/gitignore/*.gitignore -exec basename {} \; \
 | 
				
			||||||
 | 
					        | sed 's/\(.*\)\.gitignore/\1/' \
 | 
				
			||||||
 | 
					        | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down'
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if ! [[ -z $gitignore_template ]]; then
 | 
				
			||||||
 | 
					    gitignore="$GGROOT/github.com/github/gitignore/$gitignore_template.gitignore"
 | 
				
			||||||
 | 
					    echo "$gitignore"
 | 
				
			||||||
 | 
					    echo "$project/.gitignore"
 | 
				
			||||||
 | 
					    cat "$gitignore" >>"$project/.gitignore"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					license_template=$(
 | 
				
			||||||
 | 
					    find "$GGROOT"/git.janezic.dev/janezicmatej/license/*.license -exec basename {} \; \
 | 
				
			||||||
 | 
					        | sed 's/\(.*\)\.license/\1/' \
 | 
				
			||||||
 | 
					        | fzf --cycle --bind 'tab:toggle-up,btab:toggle-down'
 | 
				
			||||||
 | 
					)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if ! [[ -z $license_template ]]; then
 | 
				
			||||||
 | 
					    license="$GGROOT/git.janezic.dev/janezicmatej/license/$license_template.license"
 | 
				
			||||||
 | 
					    export YEAR="$(date '+%Y')"
 | 
				
			||||||
 | 
					    envsubst <"$license" >"$project/LICENSE"
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ggcompile
 | 
				
			||||||
@@ -37,4 +37,4 @@ bind-key F run-shell "tmux neww ~/.config/tmux/tmux-ssher"
 | 
				
			|||||||
bind-key T run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/temp"
 | 
					bind-key T run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~/temp"
 | 
				
			||||||
bind-key R run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~"
 | 
					bind-key R run-shell "tmux neww ~/.config/tmux/tmux-sessionizer ~"
 | 
				
			||||||
bind-key G run-shell "tmux neww ~/.config/tmux/tmux-ggclone"
 | 
					bind-key G run-shell "tmux neww ~/.config/tmux/tmux-ggclone"
 | 
				
			||||||
 | 
					bind-key N run-shell "tmux neww ~/.config/tmux/tmux-new-project"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -45,3 +45,5 @@ export GPG_TTY=$TTY
 | 
				
			|||||||
export USER_UID=$(id -u)
 | 
					export USER_UID=$(id -u)
 | 
				
			||||||
export USER_GID=$(id -g)
 | 
					export USER_GID=$(id -g)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# name
 | 
				
			||||||
 | 
					export NAME="Matej Janežič"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,9 +1,8 @@
 | 
				
			|||||||
alias s="ssh"
 | 
					 | 
				
			||||||
alias z="exec zsh"
 | 
					alias z="exec zsh"
 | 
				
			||||||
alias t="tmux a || tmux new-session -s $(whoami) -c ~"
 | 
					alias t="tmux a || tmux new-session -s $(whoami) -c ~"
 | 
				
			||||||
alias n=nvim_ve
 | 
					alias n=nvim_ve
 | 
				
			||||||
# alias vim=nvim_ve
 | 
					# alias vim=nvim_ve
 | 
				
			||||||
alias ssh-hosts="grep -P \"^Host ([^*]+)$\" $HOME/.ssh/config | sed 's/Host //'"
 | 
					alias s="ssh-menu"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# navigation
 | 
					# navigation
 | 
				
			||||||
alias cdgit="cd $GGROOT"
 | 
					alias cdgit="cd $GGROOT"
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										175
									
								
								zsh/scripts.zsh
									
									
									
									
									
								
							
							
						
						
									
										175
									
								
								zsh/scripts.zsh
									
									
									
									
									
								
							@@ -1,125 +1,138 @@
 | 
				
			|||||||
 | 
					 | 
				
			||||||
function nvim_ve {
 | 
					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"
 | 
					        source "$VIRTUAL_ENV/bin/activate"
 | 
				
			||||||
    command nvim $@
 | 
					        command nvim $@
 | 
				
			||||||
    deactivate
 | 
					        deactivate
 | 
				
			||||||
  else
 | 
					    else
 | 
				
			||||||
    command nvim $@
 | 
					        command nvim $@
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
alias nvim=nvim_ve
 | 
					alias nvim=nvim_ve
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ffb {
 | 
					function ffb {
 | 
				
			||||||
  if ! [[ -f package.json ]]; then
 | 
					    if ! [[ -f package.json ]]; then
 | 
				
			||||||
    echo "no package.json"
 | 
					        echo "no package.json"
 | 
				
			||||||
    return
 | 
					        return
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ -f yarn.lock ]]; then
 | 
					    if [[ -f yarn.lock ]]; then
 | 
				
			||||||
    PACKAGE_MANAGER=yarn
 | 
					        PACKAGE_MANAGER=yarn
 | 
				
			||||||
  else
 | 
					    else
 | 
				
			||||||
    PACKAGE_MANAGER=npm
 | 
					        PACKAGE_MANAGER=npm
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ -n $(grep "react-scripts" package.json) ]]; then
 | 
					    if [[ -n $(grep "react-scripts" package.json) ]]; then
 | 
				
			||||||
    BROWSER=none FORCE_COLOR=true "$PACKAGE_MANAGER" start | cat
 | 
					        BROWSER=none FORCE_COLOR=true "$PACKAGE_MANAGER" start | cat
 | 
				
			||||||
  fi
 | 
					    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)
 | 
				
			||||||
  if [[ $COUNT -ge 0 ]]; then
 | 
					    if [[ $COUNT -ge 0 ]]; then
 | 
				
			||||||
    VER=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).version')
 | 
					        VER=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).version')
 | 
				
			||||||
    # OP=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).requirement?[0][0]')
 | 
					        # OP=$(echo "$RES" | jq '.[] | select(.name | contains("'"$2"'")).requirement?[0][0]')
 | 
				
			||||||
    # echo "$2""$(echo "$OP" | tr -d '"')""$(echo "$VER" | tr -d '"')"
 | 
					        # echo "$2""$(echo "$OP" | tr -d '"')""$(echo "$VER" | tr -d '"')"
 | 
				
			||||||
    echo "$2""==""$(echo "$VER" | tr -d '"')"
 | 
					        echo "${2}==$(echo "$VER" | tr -d '"')"
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
function nukepip {
 | 
					function nukepip {
 | 
				
			||||||
  pip uninstall $(pip freeze) -y
 | 
					    pip uninstall $(pip freeze) -y
 | 
				
			||||||
  pip install -r $(pyenv root)/default-packages
 | 
					    pip install -r $(pyenv root)/default-packages
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function pyinit {
 | 
					function pyinit {
 | 
				
			||||||
  if [[ -f .python-version ]]; then 
 | 
					    if [[ -f .python-version ]]; then
 | 
				
			||||||
    echo "found .python-version, stopping"
 | 
					        echo "found .python-version, stopping"
 | 
				
			||||||
    return
 | 
					        return
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  DIRNAME=$(basename "$PWD")
 | 
					    DIRNAME=$(basename "$PWD")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ $(pyenv versions | grep -E "/${DIRNAME}$") ]]; then
 | 
					    if [[ $(pyenv versions | grep -E "/${DIRNAME}$") ]]; then
 | 
				
			||||||
    echo "found existing version with this name, setting..."
 | 
					        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"
 | 
				
			||||||
    pyenv local "$DIRNAME"
 | 
					    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"
 | 
					 | 
				
			||||||
  pyenv local "$DIRNAME"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function lh {
 | 
					function lh {
 | 
				
			||||||
  if [[ -z $1 ]]; then
 | 
					    if [[ -z $1 ]]; then
 | 
				
			||||||
    PORT=8000
 | 
					        PORT=8000
 | 
				
			||||||
  else
 | 
					    else
 | 
				
			||||||
    PORT=$1
 | 
					        PORT=$1
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  open "http://localhost:$PORT"
 | 
					    open "http://localhost:$PORT"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function dps {
 | 
					function dps {
 | 
				
			||||||
  if [[ -z $1 ]]; then
 | 
					    if [[ -z $1 ]]; then
 | 
				
			||||||
    docker ps --format table'{{ .ID }}\t{{ .Image }}\t{{ .Ports}}\t{{ .Names }}'
 | 
					        docker ps --format table'{{ .ID }}\t{{ .Image }}\t{{ .Ports}}\t{{ .Names }}'
 | 
				
			||||||
  else
 | 
					    else
 | 
				
			||||||
    docker ps --format table'{{ .ID }}\t{{ .Image }}\t{{ .Ports}}\t{{ .Names }}' | grep $1
 | 
					        docker ps --format table'{{ .ID }}\t{{ .Image }}\t{{ .Ports}}\t{{ .Names }}' | grep $1
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
function get_dump {
 | 
					function get_dump {
 | 
				
			||||||
  if [[ -z $1 ]]; then
 | 
					    if [[ -z $1 ]]; then
 | 
				
			||||||
    echo "provide ssh host"
 | 
					        echo "provide ssh host"
 | 
				
			||||||
    return
 | 
					        return
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ -z $2 ]]; then
 | 
					    if [[ -z $2 ]]; then
 | 
				
			||||||
    echo "provide dump destination"
 | 
					        echo "provide dump destination"
 | 
				
			||||||
    return
 | 
					        return
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  selected=$(ssh "$1" docker ps --format "{{.Names}}" | fzf)
 | 
					    selected=$(ssh "$1" docker ps --format "{{.Names}}" | fzf)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if [[ -z $selected ]]; then
 | 
					    if [[ -z $selected ]]; then
 | 
				
			||||||
    return
 | 
					        return
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  ssh "$1" docker exec "$selected" pg_dump -U db --format=c db > "$2$(date +'%Y-%m-%dT%H.%M.%S%z')"
 | 
					    ssh "$1" docker exec "$selected" pg_dump -U db --format=c db >"$2$(date +'%Y-%m-%dT%H.%M.%S%z')"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
function ggcompile {
 | 
					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 {
 | 
					function tssh {
 | 
				
			||||||
  if [[ -z $1 ]]; then
 | 
					    if [[ -z $1 ]]; then
 | 
				
			||||||
    echo "provide ssh host"
 | 
					        echo "provide ssh host"
 | 
				
			||||||
    return
 | 
					        return
 | 
				
			||||||
  fi
 | 
					    fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
   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"
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user