| delorie.com/archives/browse.cgi | search |
| X-Recipient: | archive-cygwin AT delorie DOT com |
| X-SWARE-Spam-Status: | No, hits=-1.7 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_NONE,T_RP_MATCHES_RCVD,UNPARSEABLE_RELAY |
| X-Spam-Check-By: | sourceware.org |
| Message-ID: | <4F4BB942.80906@t-online.de> |
| Date: | Mon, 27 Feb 2012 18:11:30 +0100 |
| From: | Christian Franke <Christian DOT Franke AT t-online DOT de> |
| User-Agent: | Mozilla/5.0 (Windows NT 6.1; WOW64; rv:7.0.1) Gecko/20110928 Firefox/7.0.1 SeaMonkey/2.4.1 |
| MIME-Version: | 1.0 |
| To: | cygwin AT cygwin DOT com |
| Subject: | [PATCH] base-files-4.0.9: Change prompt if running with admin rights |
| X-IsSubscribed: | yes |
| Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
| List-Id: | <cygwin.cygwin.com> |
| List-Subscribe: | <mailto:cygwin-subscribe AT cygwin DOT com> |
| List-Archive: | <http://sourceware.org/ml/cygwin/> |
| List-Post: | <mailto:cygwin AT cygwin DOT com> |
| List-Help: | <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs> |
| Sender: | cygwin-owner AT cygwin DOT com |
| Mail-Followup-To: | cygwin AT cygwin DOT com |
| Delivered-To: | mailing list cygwin AT cygwin DOT com |
--------------090109070801040607040301
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
This is an updated version of:
http://cygwin.com/ml/cygwin/2011-04/msg00020.html
Uses the detection method suggested here:
http://cygwin.com/ml/cygwin/2011-04/msg00372.html
Tested with bash, dash, mksh, posh, and zsh (with symlink /etc/zprofile
-> profile) on cygwin 1.7.11-1 and Win7 x64.
OT: posh -l does not execute /etc/profile by default. Bug?
Christian
--------------090109070801040607040301
Content-Type: text/x-patch;
name="base-files-4.0-9-rootprompt.patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
filename="base-files-4.0-9-rootprompt.patch"
diff -rup base-files-4.0-9.orig/etc/defaults/etc/bash.bashrc base-files-4.0-9/etc/defaults/etc/bash.bashrc
--- base-files-4.0-9.orig/etc/defaults/etc/bash.bashrc 2012-02-12 22:13:04.000000000 +0100
+++ base-files-4.0-9/etc/defaults/etc/bash.bashrc 2012-02-27 16:04:40.834657800 +0100
@@ -24,7 +24,7 @@
[[ "$-" != *i* ]] && return
# Set a default prompt of: user AT host and current_directory
-PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n\$ '
+PS1='\[\e]0;\w\a\]\n\[\e[32m\]\u@\h \[\e[33m\]\w\[\e[0m\]\n'"${PS1a:-\\\$ }"
# Uncomment to use the terminal colours set in DIR_COLORS
# eval "$(dircolors -b /etc/DIR_COLORS)"
diff -rup base-files-4.0-9.orig/etc/defaults/etc/profile base-files-4.0-9/etc/defaults/etc/profile
--- base-files-4.0-9.orig/etc/defaults/etc/profile 2012-02-12 22:13:04.000000000 +0100
+++ base-files-4.0-9/etc/defaults/etc/profile 2012-02-27 16:07:51.212574600 +0100
@@ -100,6 +100,12 @@ else
cd "${HOME}" || echo "WARNING: Failed attempt to cd into ${HOME}!"
fi
+# Set PS1a if user has admin rights
+unset PS1a
+if [ -r /proc/registry/HKEY_LOCAL_MACHINE/SECURITY ]; then
+ PS1a="# "
+fi
+
# Shell dependent settings
profile_d ()
{
@@ -116,19 +122,20 @@ if [ ! "x${BASH_VERSION}" = "x" ]; then
elif [ ! "x${KSH_VERSION}" = "x" ]; then
typeset -l HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
- PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
+ PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n'"${PS1a:-\$ }")
elif [ ! "x${ZSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
profile_d zsh
- PS1='(%n@%m)[%h] %~ %% '
+ PS1='(%n@%m)[%h] %~ '"${PS1a:-%% }"
elif [ ! "x${POSH_VERSION}" = "x" ]; then
HOSTNAME="$(/usr/bin/hostname)"
- PS1="$ "
+ PS1="${PS1a:-\$ }"
else
HOSTNAME="$(/usr/bin/hostname)"
profile_d sh
- PS1="$ "
+ PS1="${PS1a:-\$ }"
fi
+unset PS1a
export PATH MANPATH INFOPATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp
--------------090109070801040607040301
Content-Type: text/plain; charset=us-ascii
--
Problem reports: http://cygwin.com/problems.html
FAQ: http://cygwin.com/faq/
Documentation: http://cygwin.com/docs.html
Unsubscribe info: http://cygwin.com/ml/#unsubscribe-simple
--------------090109070801040607040301--
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |