|
Guides All Guides and HOWTO's. |
|
Thread Tools | Display Modes |
|
|||
OpenBSD: modify .profile for PS1 and PAGER
A small script to modify PS1 and PAGER
Code:
# --------------------------------------------------------- # /.profile used to be a hard link to /root/.profile so only one needed # to be modified # Not true anymore : # ls -il /.profile /root/.profile # 24 -rw-r--r-- 1 root wheel 411 Jan 15 22:33 /.profile # 4182 -rw-r--r-- 1 root wheel 440 Jan 18 01:13 /root/.profile PROFILES="/.profile /root/.profile /etc/skel/.profile" echo Modifying PS1 in ${PROFILES} for file in $PROFILES ; do echo "$0: adding prompt to: $file" cat <<-END >>$file # --- prompt # j65nko@zeno[/home/j65nko/] # \u @ \h [ \w ] PS1="\u@\h[\w]" export PS1 export PAGER=/usr/bin/less END done Code:
<< marker After reading the command line containing this kind of redirec- tion (called a ``here document''), the shell copies lines from the command source into a temporary file until a line matching marker is read. When the command is executed, standard input is redirected from the temporary file. If marker contains no quoted characters, the contents of the temporary file are processed as if enclosed in double quotes each time the command is executed, so parameter, command, and arithmetic substitutions are per- formed, along with backslash (`\') escapes for `$', ``', `\', and `\newline'. If multiple here documents are used on the same com- mand line, they are saved in order. <<- marker Same as <<, except leading tabs are stripped from lines in the here document. You only have to use this when you want the here document to align nicely inside a loop like here. Be aware that this only strips leading tabs and not leading spaces. You can verify with cat whether there are really tabs and not spaces Code:
$ cat -nt [snip] 15 for file in $PROFILES ; do 16 echo "$0: adding prompt to: $file" 17 cat <<-END >>$file 18 19 ^I# --- prompt 20 ^I# j65nko@zeno[/home/j65nko/] 21 ^I# \u @ \h [ \w ] 22 23 ^IPS1="\u@\h[\w]" 24 ^Iexport PS1 25 ^Iexport PAGER=/usr/bin/less 26 END 27 done If you past the scirpt, then those tabs usually disappear: Code:
$ cat -net pasted 1 $ 2 for file in $PROFILES ; do$ 3 echo "$0: adding prompt to: $file"$ 4 cat <<-END >>$file$ 5 $ 6 # --- prompt$ 7 # j65nko@zeno[/home/j65nko/] $ 8 # \u @ \h [ \w ]$ 9 $ 10 PS1="\u@\h[\w]"$ 11 export PS1$ 12 export PAGER=/usr/bin/less$ 13 END$ Code:
# ls -l /etc/skel -rw-r--r-- 1 root wheel 22 Jan 15 22:33 .Xdefaults -rw-r--r-- 1 root wheel 773 Jan 15 22:33 .cshrc -rw-r--r-- 1 root wheel 398 Jan 15 22:33 .login -rw-r--r-- 1 root wheel 113 Jan 15 22:33 .mailrc -rw-r--r-- 1 root wheel 265 Jan 18 05:02 .profile drwx------ 2 root wheel 512 Jan 15 22:33 .ssh
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump Last edited by J65nko; 19th January 2010 at 01:50 AM. Reason: Enlarged fornt for "<< marker" and "<<-marker" |
|
||||
My way of being lazy, is simply called git.
__________________
My Journal Thou shalt check the array bounds of all strings (indeed, all arrays), for surely where thou typest ``foo'' someone someday shall type ``supercalifragilisticexpialidocious''. |
Tags |
.profile, /etc/skel, here document, ps1 prompt |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to modify the ls command? | bsdnewbie999 | OpenBSD General | 9 | 16th May 2009 08:20 AM |
read & modify files out side chroot jail | Dr_Death_UAE | FreeBSD Security | 5 | 6th November 2008 09:20 PM |
Modify host-level firewall rules (without getting locked out) | anomie | Guides | 13 | 16th June 2008 04:26 AM |
Which light Gui from modify images files? | aleunix | OpenBSD General | 7 | 15th June 2008 04:32 PM |
How to modify the boot loader? | Sunsawe | FreeBSD General | 5 | 29th May 2008 05:13 AM |