unofficial mirror of guix-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: 宋文武 <iyzsong@gmail.com>
To: guix-devel@gnu.org
Subject: Re: use zsh as login shell
Date: Fri, 05 Dec 2014 21:57:19 +0800	[thread overview]
Message-ID: <874mtafbcw.fsf@gmail.com> (raw)
In-Reply-To: <87k32gtz2p.fsf@gmail.com>

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

Here are my new patches:
Yeh, just add ~/.zshrc to source /etc/profie is enough.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-system-Cleanup-bash-startup-files.patch --]
[-- Type: text/x-patch, Size: 3730 bytes --]

From 42ccd7a445c9676db6d2c7b2b0583db45be245aa Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 5 Dec 2014 20:01:07 +0800
Subject: [PATCH 1/2] system: Cleanup bash startup files.

* gnu/system.scm (etc-directory) (bashrc): Rename to (profile).
  'CPATH', 'LIBRARY_PATH': Remove.
  'PS1', 'alias ls', 'alias ll': Move to ...
* gnu/system/shadow.scm (default-skeletons):
  (.bashrc): ... here. Don't source /etc/profile.
  (.bash_profile): New skeleton.
---
 gnu/system.scm        | 13 ++++---------
 gnu/system/shadow.scm | 13 +++++++++----
 2 files changed, 13 insertions(+), 13 deletions(-)

diff --git a/gnu/system.scm b/gnu/system.scm
index e1ed1a2..a851ff2 100644
--- a/gnu/system.scm
+++ b/gnu/system.scm
@@ -384,10 +384,9 @@ This is the GNU system.  Welcome.\n")
        (nsswitch   (text-file "nsswitch.conf"
                               "hosts: files dns\n"))
 
-       ;; TODO: Generate bashrc from packages' search-paths.
-       (bashrc    (text-file* "bashrc"  "
-export PS1='\\u@\\h \\w\\$ '
-
+       ;; Startup file for POSIX-compliant login shells, which set system-wide
+       ;; environment variables.
+       (profile    (text-file* "profile"  "\
 export LC_ALL=\"" locale "\"
 export TZ=\"" timezone "\"
 export TZDIR=\"" tzdata "/share/zoneinfo\"
@@ -397,11 +396,7 @@ export LINUX_MODULE_DIRECTORY=/run/booted-system/kernel/lib/modules
 
 export PATH=$HOME/.guix-profile/bin:/run/current-system/profile/bin
 export PATH=/run/setuid-programs:/run/current-system/profile/sbin:$PATH
-export CPATH=$HOME/.guix-profile/include:" profile "/include
-export LIBRARY_PATH=$HOME/.guix-profile/lib:" profile "/lib
 export INFOPATH=$HOME/.guix-profile/share/info:/run/current-system/profile/share/info
-alias ls='ls -p --color'
-alias ll='ls -l'
 "))
        (skel      (skeleton-directory skeletons)))
     (file-union "etc"
@@ -414,7 +409,7 @@ alias ll='ls -l'
                   ("nsswitch.conf" ,#~#$nsswitch)
                   ("skel" ,#~#$skel)
                   ("shells" ,#~#$shells)
-                  ("profile" ,#~#$bashrc)
+                  ("profile" ,#~#$profile)
                   ("hosts" ,#~#$hosts-file)
                   ("localtime" ,#~(string-append #$tzdata "/share/zoneinfo/"
                                                  #$timezone))
diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index 6970021..4a2322b 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -115,9 +115,13 @@
         (copy-file (car (find-files #$guile-wm "wm-init-sample.scm"))
                    #$output)))
 
-  (mlet %store-monad ((bashrc (text-file "bashrc" "\
-# Allow non-login shells such as an xterm to get things right.
-test -f /etc/profile && source /etc/profile\n"))
+  (mlet %store-monad ((profile (text-file "bash_profile" "\
+# Honor per-interactive-shell startup file
+if [ -f ~/.bashrc ]; then . ~/.bashrc; fi\n"))
+                      (bashrc (text-file "bashrc" "\
+PS1='\\u@\\h \\w\\$ '
+alias ls='ls -p --color'
+alias ll='ls -l'\n"))
                       (guile-wm (gexp->derivation "guile-wm" copy-guile-wm
                                                   #:modules
                                                   '((guix build utils))))
@@ -127,7 +131,8 @@ XTerm*metaSendsEscape: true\n"))
                       (gdbinit   (text-file "gdbinit" "\
 # Tell GDB where to look for separate debugging files.
 set debug-file-directory ~/.guix-profile/lib/debug\n")))
-    (return `((".bashrc" ,bashrc)
+    (return `((".bash_profile" ,profile)
+              (".bashrc" ,bashrc)
               (".Xdefaults" ,xdefaults)
               (".guile-wm" ,guile-wm)
               (".gdbinit" ,gdbinit)))))
-- 
2.1.2


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #3: 0002-system-Add-skeleton-.zshrc.patch --]
[-- Type: text/x-patch, Size: 1324 bytes --]

From 043e4d9b6743654e048d3495cb5bfa592d17e6c4 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E5=AE=8B=E6=96=87=E6=AD=A6?= <iyzsong@gmail.com>
Date: Fri, 5 Dec 2014 21:17:49 +0800
Subject: [PATCH 2/2] system: Add skeleton '.zshrc'.

* gnu/system/shadow.scm (default-skeletons): Add .zshrc.
---
 gnu/system/shadow.scm | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gnu/system/shadow.scm b/gnu/system/shadow.scm
index 4a2322b..a0b9f56 100644
--- a/gnu/system/shadow.scm
+++ b/gnu/system/shadow.scm
@@ -122,6 +122,9 @@ if [ -f ~/.bashrc ]; then . ~/.bashrc; fi\n"))
 PS1='\\u@\\h \\w\\$ '
 alias ls='ls -p --color'
 alias ll='ls -l'\n"))
+                      (zshrc (text-file "zshrc" "\
+# Honor system-wide environment variables
+source /etc/profile\n"))
                       (guile-wm (gexp->derivation "guile-wm" copy-guile-wm
                                                   #:modules
                                                   '((guix build utils))))
@@ -133,6 +136,7 @@ XTerm*metaSendsEscape: true\n"))
 set debug-file-directory ~/.guix-profile/lib/debug\n")))
     (return `((".bash_profile" ,profile)
               (".bashrc" ,bashrc)
+              (".zshrc" ,zshrc)
               (".Xdefaults" ,xdefaults)
               (".guile-wm" ,guile-wm)
               (".gdbinit" ,gdbinit)))))
-- 
2.1.2


[-- Attachment #4: Type: text/plain, Size: 284 bytes --]


I find `su` to bash will give a non-useable shell with
PATH set to '/sbin:/bin:/usr/sbin:/usr/bin'. This is because su/pam
reset the PATH to this default value. To solve this, we can add
/etc/environment and use pam_env.so for su. (imo not worth it :)

`su -l` and `sudo` work fine.

  parent reply	other threads:[~2014-12-05 13:59 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-11-27 15:58 use zsh as login shell 宋文武
2014-11-27 20:15 ` Ludovic Courtès
2014-11-28 15:06   ` 宋文武
2014-11-28 22:26     ` Ludovic Courtès
2014-11-29  3:24       ` 宋文武
2014-12-01 12:57         ` Ludovic Courtès
2014-12-02 14:43           ` 宋文武
2014-12-04 23:10             ` Ludovic Courtès
2014-12-05  5:11               ` Mark H Weaver
2014-12-05 18:54                 ` Ludovic Courtès
2014-12-05 11:21               ` 宋文武
2014-12-06  8:04                 ` use zsh and fish " 宋文武
2014-12-06 15:09                   ` Ludovic Courtès
2014-11-28 15:11   ` use zsh " 宋文武
2014-12-05 13:57 ` 宋文武 [this message]
2014-12-06 22:35   ` /etc/profile and .zshrc skeleton Ludovic Courtès
2014-12-07  4:06     ` 宋文武
2014-12-07 20:35       ` Ludovic Courtès

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=874mtafbcw.fsf@gmail.com \
    --to=iyzsong@gmail.com \
    --cc=guix-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

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