From d2a9a24f49a894c3f21801a74d791a640b1b275d Mon Sep 17 00:00:00 2001 From: Joe Groocock Date: Tue, 3 Jul 2018 20:47:23 +0100 Subject: [PATCH] Replace ppwd with inline sed expression --- Dockerfile | 1 - skel/etc/profile | 2 +- skel/usr/bin/ppwd | 19 ------------------- 3 files changed, 1 insertion(+), 21 deletions(-) delete mode 100644 skel/usr/bin/ppwd diff --git a/Dockerfile b/Dockerfile index 2efa185..3ca2e1a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -121,7 +121,6 @@ COPY --from=builder /output/ / # Add default skeleton configuration files COPY skel/ / RUN chmod 1777 /tmp && \ - chmod 775 /usr/bin/* && \ chmod u+s /usr/bin/ping /usr/bin/su ENV ENV="/etc/profile" diff --git a/skel/etc/profile b/skel/etc/profile index 6e8b773..5da8e40 100644 --- a/skel/etc/profile +++ b/skel/etc/profile @@ -1,6 +1,6 @@ export PAGER='/usr/bin/less -R' export EDITOR='/usr/bin/vi' -export PS1='\e[1;36m\u@\h\e[0m \e[0;32m$(ppwd)\e[0m> ' +export PS1='\e[1;36m\u@\h\e[0m \e[0;32m$(pwd | sed -E '"'s|^'\$HOME'|~|;s|(.*)/|\\1%#|;s|((^\\|/)\\.?[^/%]{1})[^/%]*|\\1|g;s|(.*)%#|\\1/|')"'\e[0m> ' # Source configuration files from /etc/profile.d for i in /etc/profile.d/*.sh ; do diff --git a/skel/usr/bin/ppwd b/skel/usr/bin/ppwd deleted file mode 100644 index 7b52105..0000000 --- a/skel/usr/bin/ppwd +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/sh -set -e -o pipefail - -dir="$(echo -n "${1:-$PWD}" | sed "s|$HOME|~|")" - -if [ "$dir" = '~' -o "$dir" = '/' ]; then - echo "$dir" - exit 0 -fi - -parts="$(echo "$dir" | tr '/' '\n' | sed '$d')" -last="$(echo "$dir" | tr '/' '\n' | tail -n 1)" - -for d in "$parts"; do - out="$out$(echo "$d" | sed -E '/^\./s/^(.{2}).*/\1/;/^[^\.]/s/^(.{1}).*/\1/')\n" -done - -echo -en "$out" | tr '\n' '/' -echo "$last" \ No newline at end of file