1
0
mirror of https://github.com/bingohuang/docker-labs.git synced 2025-07-13 01:02:42 +08:00

Add fancy bash prompt from orchestration workshop (#28)

* Add bash prompt

* remove curly braces

* Change shell from ash to bash

* Add inputrc for bash
This commit is contained in:
Vincent De Smet 2016-11-30 11:12:34 +08:00 committed by Marcos Nils
parent 6371ee665e
commit d3e20724e9
5 changed files with 101 additions and 4 deletions

1
.bashrc Normal file
View File

@ -0,0 +1 @@
export PS1='\e[1m\e[31m[\h] \e[32m($(docker-prompt)) \e[34m\u@$(hostname -i)\e[35m \w\e[0m\n$ '

73
.inputrc Normal file
View File

@ -0,0 +1,73 @@
# /etc/inputrc - global inputrc for libreadline
# See readline(3readline) and `info rluserman' for more information.
# Be 8 bit clean.
set input-meta on
set output-meta on
# To allow the use of 8bit-characters like the german umlauts, uncomment
# the line below. However this makes the meta key not work as a meta key,
# which is annoying to those which don't need to type in 8-bit characters.
# set convert-meta off
# try to enable the application keypad when it is called. Some systems
# need this to enable the arrow keys.
# set enable-keypad on
# see /usr/share/doc/bash/inputrc.arrows for other codes of arrow keys
# do not bell on tab-completion
# set bell-style none
# set bell-style visible
# some defaults / modifications for the emacs mode
$if mode=emacs
# allow the use of the Home/End keys
"\e[1~": beginning-of-line
"\e[4~": end-of-line
# allow the use of the Delete/Insert keys
"\e[3~": delete-char
"\e[2~": quoted-insert
# mappings for "page up" and "page down" to step to the beginning/end
# of the history
# "\e[5~": beginning-of-history
# "\e[6~": end-of-history
# alternate mappings for "page up" and "page down" to search the history
# "\e[5~": history-search-backward
# "\e[6~": history-search-forward
# mappings for Ctrl-left-arrow and Ctrl-right-arrow for word moving
"\e[1;5C": forward-word
"\e[1;5D": backward-word
"\e[5C": forward-word
"\e[5D": backward-word
"\e\e[C": forward-word
"\e\e[D": backward-word
$if term=rxvt
"\e[7~": beginning-of-line
"\e[8~": end-of-line
"\eOc": forward-word
"\eOd": backward-word
$endif
# for non RH/Debian xterm, can't hurt for RH/Debian xterm
# "\eOH": beginning-of-line
# "\eOF": end-of-line
# for freebsd console
# "\e[H": beginning-of-line
# "\e[F": end-of-line
$endif
# faster completion
set show-all-if-ambiguous on
"\e[A": history-search-backward
"\e[B": history-search-forward

View File

View File

@ -2,7 +2,7 @@ FROM docker:1.13.0-rc2-dind
ENV DOCKER_STORAGE_DRIVER=overlay2
RUN apk add --no-cache git tmux py-pip apache2-utils vim build-base gettext-dev curl
RUN apk add --no-cache git tmux py-pip apache2-utils vim build-base gettext-dev curl bash
# Install Compose and Machine
RUN pip install docker-compose==1.9.0
@ -21,8 +21,9 @@ RUN mkdir -p /opt && cd /opt && \
# (note: we can't just symlink to /bin/true because it might be busybox)
RUN rm /sbin/modprobe && echo '#!/bin/true' >/sbin/modprobe && chmod +x /sbin/modprobe
# Install a nice vimrc file
COPY vimrc /root/.vimrc
# Install a nice vimrc file and prompt (by soulshake)
COPY ["docker-prompt","/usr/local/bin/"]
COPY [".vimrc",".bashrc", ".inputrc", "./root/"]
# Move to our home
WORKDIR /root
@ -32,5 +33,5 @@ CMD cat /etc/hosts >/etc/hosts.bak && \
sed 's/^::1.*//' /etc/hosts.bak > /etc/hosts && \
dockerd -g /graph --host=unix:///var/run/docker.sock --host=tcp://0.0.0.0:2375 \
--storage-driver=$DOCKER_STORAGE_DRIVER &>/docker.log & \
while true ; do /bin/sh ; done
while true ; do /bin/bash ; done
# ... and then put a shell in the foreground, restarting it if it exits

22
docker-prompt Executable file
View File

@ -0,0 +1,22 @@
#!/bin/sh
case "$DOCKER_HOST" in
*:3376)
echo swarm
;;
*:2376)
echo $DOCKER_MACHINE_NAME
;;
*:2375)
echo $DOCKER_MACHINE_NAME
;;
*:55555)
echo $DOCKER_MACHINE_NAME
;;
"")
echo local
;;
*)
echo unknown
;;
esac