Skip to content

Instantly share code, notes, and snippets.

@cdemers
Last active July 18, 2016 21:08
Show Gist options
  • Save cdemers/8351180dcf30753866ffac7715cc2cf3 to your computer and use it in GitHub Desktop.
Save cdemers/8351180dcf30753866ffac7715cc2cf3 to your computer and use it in GitHub Desktop.
#!/bin/sh
# Starts a bash within a container running on Kubernetes while initializing
# the terminal type to xterm and the size to your actual terminal size. Makes
# it possible to have vi, more, etc work in a usable way until PR #25273 is
# merged. Derived from a snip by Hubert Chen (https://github.com/hubt)
if [ "$1" = "" ]; then
echo "Usage: kbash.sh {pod} [container]"
exit 1
fi
if [ "$2" != "" ]; then
CNT="-c $2"
fi
COLUMNS=`tput cols`
LINES=`tput lines`
TERM=xterm
kubectl exec -ti $1 $CNT env COLUMNS=$COLUMNS LINES=$LINES TERM=$TERM bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment