eriklamp5 / workspace

0 stars 0 forks source link

Refinements on kube* #1

Open erik-grepr opened 2 months ago

erik-grepr commented 2 months ago

Misc fixes:

10:37 ~/bin $cat kubefind
#!/bin/bash

container="$1"
shift
namespace="$1"
shift

while IFS= read -r line; do
    temp="${line#pod/}"
    # echo "${temp%-[^-]*-[^-]*} ${container} ${temp} ${line}"
    if [[ "${temp%-[^-]*-[^-]*}" == "$container" ]] ; then
        echo $line
        exit
    fi
done <<< "$(kubectl get pods -o=name --namespace="$namespace")"

10:37 ~/bin $cat kubeconnect
#!/bin/bash

container="$1"
shift
namespace="$1"
shift

exec kubectl exec --stdin --tty --namespace="$namespace" "$(kubefind "$container" "$namespace")" -- /bin/bash "$@"

10:37 ~/bin $cat kubelogs
#!/bin/bash

container="$1"
shift
namespace="$1"
shift

exec kubectl logs --namespace="$namespace" "$(kubefind "$container" "$namespace")" "$@"

10:37 ~/bin $cat kubeport
#!/bin/bash

container="$1"
shift
namespace="$1"
shift
port="$1"
shift

exec kubectl port-forward --namespace="$namespace" "$(kubefind "$container" "$namespace")" "$port" "$@"

PS1 changes:

# PS1='\[\033]0;$TITLEPREFIX:$PWD\007\]\n\[\033[32m\]\u@\h \[\033[33m\]\w\[\033[36m\]`__git_ps1`\[\033[0m\]$ '
# PS1='\[\033[35m\]\A \[\033[33m\]\w\[\033[36m\]`__git_ps1` \[\033[0m\]$'
export PS1_BRANCH_CUT=20
PS1='\[\033[35m\]\A \[\033[33m\]\w\[\033[36m\]`__git_ps1 | sed -E "s/(.{$PS1_BRANCH_CUT})(.+)/\1...)/"` \[\033[0m\]$'
export PS1

Misc

alias e_docker_reset='docker rm -vf $(docker ps -aq) && docker rmi -f $(docker images -aq)'

gitrm The old gitr

gitr

#!/bin/bash

if [[ "$#" -ne 0 ]] ; then
    exec git rebase -i "$@"
else
 exec git rebase -i "$( git status --branch --porcelain=2 | grep "branch.upstream" | cut -d ' ' -f 3 )^"
fi

gitad

// same as gita, only update the following line:
git add "${filename}" "$@" && gitd "$index" "$@"
erik-grepr commented 3 days ago

Updated path for ~/bins

if [ -d $DIR/bins ]; then
    for filename in $DIR/bins/*; do
        [[ ":$PATH:" != *":${filename}/bin:"* ]] && PATH="${filename}/bin:$PATH"
    done
fi
if [ -d $DIR/bin ]; then
    [[ ":$PATH:" != *":$DIR/bin:"* ]] && PATH="$DIR/bin:$PATH"
fi