Make kc a zsh function instead of script

This commit is contained in:
Pavle Portic 2022-11-03 21:39:16 +01:00
parent e5a24d1dda
commit 124518c691
Signed by: TheEdgeOfRage
GPG Key ID: 66AD4BA646FBC0D2
3 changed files with 5 additions and 22 deletions

View File

@ -1,10 +1,4 @@
#!/usr/bin/env bash
[[ -n $DEBUG ]] && set -x
set -eou pipefail
IFS=$'\n\t'
#!/bin/zsh
usage() {
local SELF
@ -32,7 +26,7 @@ current_context() {
get_configs() {
#kubectl config get-contexts -o=name | sort -n
ls -p --color=never -1 $HOME/.kube | grep -v '/$'
ls -p --color=never -1 $HOME/.kube | \grep -v '/$'
}
list_configs() {
@ -77,19 +71,15 @@ choose_context_interactive() {
}
set_context() {
echo "Set context to ${1}." >&2
export KUBECONFIG="$HOME/.kube/${1}"
echo -e "\n\nYou are in a subshell. Press Ctrl+d for exit!\n\n"
$SHELL
}
unset_context() {
echo "Unsetting current context." >&2
unset $KUBECONFIG
kubectl config unset current-context
echo "Ctrl+d for exiting subshell." >&2
}
main() {
kc() {
if [[ "$#" -eq 0 ]]; then
if [[ -t 1 && -z "${KUBECTX_IGNORE_FZF:-}" && "$(type fzf &>/dev/null; echo $?)" -eq 0 ]]; then
choose_context_interactive
@ -124,5 +114,3 @@ main() {
exit 1
fi
}
main "$@"

View File

@ -1,3 +0,0 @@
#!/bin/zsh
ffmpeg -n -i "$1" -acodec libmp3lame -ab 320k -map_metadata 0 -id3v2_version 3 "$2" &> /dev/null

View File

@ -42,6 +42,7 @@ bindkey -v
source ${CUSTOM}/completions/*.zsh
source ~/.aliases
source ~/.config/zsh/kc.zsh
# Variable exports
export DEFAULT_USER="pavle"
@ -94,8 +95,5 @@ if which pyenv &> /dev/null; then
eval "$(pyenv init -)"
fi
# Nvm settings
[[ -f /usr/share/nvm/init-nvm.sh ]] && source /usr/share/nvm/init-nvm.sh
# startx on tty1
if [[ -z $DISPLAY ]] && [[ $(tty) = /dev/tty1 ]]; then exec startx -- vt1; fi