[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: How to get Dot files out of the way via shell scripts



On Jo, 11 iul 13, 07:12:35, Wilko Fokken wrote:
> 
> The following lines explain, what should be done in order to get the dot
> files out of the way into a subdirectory.

You included lots of unrelated customizations, see below.

> The dot files of root  go into subdir "/root/"

Err, aren't they already there by default?

> The dot files of users go into subdir "/home/$HOME/.rc/"

I'd go for /home/$user/.config (the default XDG directory). 
 
> HowTo get Dot Files into separate Subdirs at Installation Time
> ==============================================================
> wfokken@web.de	July 11 2013	
> 
> ( set tabwidth = 4 to view this file )
> 
> 
> 1.	Modify /etc/skel
> 	================
> 
> 	[from]:
> 	-rw-r--r--   1 root root   220 Jan  1  2013 .bash_logout
> 	-rw-r--r--   1 root root  3392 Jan  1  2013 .bashrc
> 	-rw-r--r--   1 root root   675 Jan  1  2013 .profile
> 
> 	[to]:
> 	-rw-r--r--   1 root root   220 Jan  1  2013 .rc/.bash_logout
> 	-rw-r--r--   1 root root  3392 Jan  1  2013 .rc/.bashrc
> 	-rw-r--r--   1 root root   675 Jan  1  2013 .rc/.profile
 
Ok, but this only affects new users. For existing accounts one has to 
move the files by hand.
 
> 	[ these three files in .rc/ need to be edited ] :
> 	-------------------------------------------------
> 
> a)	.bash_logout:
> 	-------------
> 	# ~/.bash_logout: executed by bash(1) on logout:
> 	# clear screen (here = max. 24 virtual text consoles)
> 	# [ enhance ## of text consoles: add entries in /etc/inittab ] 
> 
> 	case "`tty`" in
> 	  /dev/tty[1-9] | /dev/tty1[0-9] | /dev/tty2[0-4] ) clear
> 	esac

This is not necessary for the task at hand and the default .bash_logout 
already does similar (and better, it doesn't clear *all* consoles, just 
because I logged out of one).

> b)	.bashrc:
> 	--------
> 	# ~/.bashrc: executed by bash(1) for non-login shells.
> 	# see /usr/share/doc/bash/examples/startup-files
> 
> 	. /etc/profile

See bash(1) for why this is not needed.

> c)	.profile:
> 	---------
> 
> 	# ~/.profile, at login autoread by all Bourne-compatible shells (after /etc/profile)
> 	# ~/.profile is *NOT* executed by bash shell if ~/.bash_profile exists
> 	# All 2nd level bash shells will read ~/.bashrc
> 
> 	# add wanted user owned subdirs,
> 	# (e.g. sh = shell, pl = perl, py = python scripts) :
> 
> 	for DIR in /home/$LOGNAME/bin /home/$LOGNAME/sh /home/$LOGNAME/pl \
> 		/home/$LOGNAME/py; do
> 		[ -d $DIR ] && PATH=$PATH:$DIR
> 	done

These seem to be your own customizations and don't seem to apply to the 
task at hand.

> 	PATH=$PATH:.

Are you sure this is a good idea?

> 	export PATH PS1 PS2
> 
> 	# mesg y
> 
> 	# 'cd' command (below) moves login `pwd` to  $HOME/.. !
> 	# -----------------------------------------------------
> 	# (applies new bash function 'cd ()')
> 	# (defined in /etc/profile/profile.local)
> 
> 	cd
> 
> 
> 2.	Within /root, modify .bashrc, .profile :
> 	========================================
> 
> 	prepend	command:	"./etc/profile"		to  .bashrc

Are you missing a space here?

> 	append	command:	"cd"				to  .profile
> 
> 
> 3.  Modify /etc/passwd: login_dir ==> /home/<user>/.rc
> 	==================================================
> 	
> 	example:
> 	wwf:x:1001:1001:Wilko Fokken,,,:/home/wwf/.rc:/bin/bash

So basically you're setting $HOME to be /home/$user/.rc

> 4.	/etc/profile	Add call to homebrew /etc/profile.local:
> 	========================================================
> 	(keeps original condition of /etc/profile)
> 
> 	# ----------------------------------------------------
> 	test -f /etc/profile.local     && . /etc/profile.local
> 	test -f ~/.alias.sh            && . ~/.alias.sh
> 	# ----------------------------------------------------
> 
> 
> 5.	# /etc/profile.local: Modifications to login process
> 	# ==================================================
> 
> 	# umask 022
> 
> 	# Unclutter root's and user's HOME_dir:
> 	# -------------------------------------
> 	# root:  $HOME => /root				$CDHOME => /
> 	# users: $HOME => /home/<user>/.rc;	$CDHOME => /home/<user>
> 
> 	# cutting off {/root | /.rc} from "LOGIN_dir" :
> 
> 	CDHOME=`dirname $HOME`
> 
> 	# "cd" (no params): Go to "LOGIN_dir", NOT to "LOGIN_dir"/.rc :
> 	
> 	cd ()  {
> 		[ $1 ] && builtin cd $1 || builtin cd ${CDHOME}
> 	}	

And you are customizing 'cd' to take you to /home/$user/ instead of 
/home/$user/.rc

> 	export PATH CDHOME HOME HISTFILE
> 
> 	# ================================================= #
> 	# End of functions supporting displaced dot files ! #
> ======================================================================
> 
> 	# (The following lines are NOT directly related to dot files) :

Why include them then?

[snip unrelated customizations]

Kind regards,
Andrei
-- 
http://wiki.debian.org/FAQsFromDebianUser
Offtopic discussions among Debian users and developers:
http://lists.alioth.debian.org/mailman/listinfo/d-community-offtopic

Attachment: signature.asc
Description: Digital signature


Reply to: