public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* [PATCH] base-files-4.2-1: Change prompt if running with admin rights
@ 2014-04-09 17:15 Christian Franke
  2014-04-09 18:32 ` Achim Gratz
  0 siblings, 1 reply; 9+ messages in thread
From: Christian Franke @ 2014-04-09 17:15 UTC (permalink / raw)
  To: cygwin

[-- Attachment #1: Type: text/plain, Size: 150 bytes --]

Thanks to Achim Gratz for adopting base-files.

Attached is an updated version of:
https://sourceware.org/ml/cygwin/2012-02/msg00806.html

Christian


[-- Attachment #2: base-files-4.2-1-rootprompt.patch --]
[-- Type: text/x-patch, Size: 2237 bytes --]

diff -rup base-files-4.2-1.orig/etc/defaults/etc/bash.bashrc base-files-4.2-1/etc/defaults/etc/bash.bashrc
--- base-files-4.2-1.orig/etc/defaults/etc/bash.bashrc	2014-03-23 14:56:28.412930900 +0100
+++ base-files-4.2-1/etc/defaults/etc/bash.bashrc	2014-04-09 13:42:05.000000000 +0200
@@ -27,7 +27,7 @@
 export EXECIGNORE="*.dll"
 
 # Set a default prompt of: user@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.2-1.orig/etc/defaults/etc/profile base-files-4.2-1/etc/defaults/etc/profile
--- base-files-4.2-1.orig/etc/defaults/etc/profile	2014-03-23 14:56:28.312931800 +0100
+++ base-files-4.2-1/etc/defaults/etc/profile	2014-04-09 12:59:43.000000000 +0200
@@ -109,6 +109,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 ()
 {
@@ -135,15 +141,17 @@ if [ ! "x${BASH_VERSION}" = "x"  ]; then
   [ -f "/etc/bash.bashrc" ] && . "/etc/bash.bashrc"
 elif [ ! "x${KSH_VERSION}" = "x" ]; then
   typeset -l HOSTNAME="$(/usr/bin/hostname)"
-  [ "${PS1-null}" = "null" ] || PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n$ ')
+  [ "${PS1-null}" = "null" ] || PS1=$(print '\033]0;${PWD}\n\033[32m${USER}@${HOSTNAME} \033[33m${PWD/${HOME}/~}\033[0m\n'"${PS1a:-\$ }")
 elif [ ! "x${ZSH_VERSION}" = "x" ]; then
   # zsh is in shell compatibility mode here, so we probably shouldn't do this
   profile_d zsh
+  [ "${PS1-null}" = "null" ] || PS1='(%n@%m)[%h] %~ '"${PS1a:-%% }"
 elif [ ! "x${POSH_VERSION}" = "x" ]; then
-  : # [ "${PS1-null}" = "null" ] || PS1="$ "
+  : # [ "${PS1-null}" = "null" ] || PS1="${PS1a:-\$ }"
 else
-  : # [ "${PS1-null}" = "null" ] || PS1="$ "
+  : # [ "${PS1-null}" = "null" ] || PS1="${PS1a:-\$ }"
 fi
+unset PS1a
 
 export PROFILEREAD PATH ORIGINAL_PATH MANPATH INFOPATH USER TMP TEMP PRINTER HOSTNAME PS1 SHELL tmp temp
 


[-- Attachment #3: Type: text/plain, Size: 218 bytes --]

--
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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2014-04-11 20:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-04-09 17:15 [PATCH] base-files-4.2-1: Change prompt if running with admin rights Christian Franke
2014-04-09 18:32 ` Achim Gratz
2014-04-09 21:51   ` Christian Franke
2014-04-10  8:11     ` Corinna Vinschen
2014-04-10 15:36       ` Achim Gratz
2014-04-10 15:57       ` Christian Franke
2014-04-10  1:50   ` Andrey Repin
2014-04-11  7:20     ` Thomas Wolff
2014-04-11 20:08       ` Christian Franke

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).