Jump to content

Account Customisation (zsh): Difference between revisions

no edit summary
No edit summary
 
(10 intermediate revisions by 3 users not shown)
Line 22: Line 22:
zsh has some system escape sequences which can be used in your command prompt also. These sequences are special characters which relate to system properties. They can be included in your command prompts to make your prompt more dynamic. Some of the common escape sequences are:
zsh has some system escape sequences which can be used in your command prompt also. These sequences are special characters which relate to system properties. They can be included in your command prompts to make your prompt more dynamic. Some of the common escape sequences are:


%d
 
Your current working directory relative to /home/
{| border="1" cellpadding="2"
%~
!width="300"|Property
Your current working directory relative to /home/member/u/username
!width="225"|Escape Sequence
%B....%b
|-
Begin and end bold print
|Your current working directory relative to /home/ || %d
%U....%u
|-
Begin and end underlined print
|Your current working directory relative to /home/member/u/username || %~
%M
|-
server name - murphy.redbrick.dcu.ie
|Begin and end bold print || %B....%b
%m
|-
The part of the hostname up to the first . - murphy
|Begin and end underlined print || %U....%u
%n
|-
Your Login Name
|server name, eg - murphy.redbrick.dcu.ie || %M
%T
|-
System time in HH:mm format
|The part of the hostname up to the first . - murphy || %m
%*
|-
System time in HH:mm:ss format
|Your Login Name || %n
%D
|-
Today's Date in YY-MM-DD
|System time in HH:mm format || %T
%l
|-
Your current tty e.g. pts/100
|System time in HH:mm:ss format || %*
|-
|Today's Date in YY-MM-DD || %D
|-
|Your current tty e.g. pts/100 || %l
|}
 


Including these in your command prompt exports allows you to have a clock on your command prompt which updates every time you press return, and you can see your current working directory to save you typing "pwd" every time you forget where you are. e.g.
Including these in your command prompt exports allows you to have a clock on your command prompt which updates every time you press return, and you can see your current working directory to save you typing "pwd" every time you forget where you are. e.g.
Line 57: Line 63:
At this point it gets a little more complicated. But with a little perseverance you can have your own customised and coloured account. The following are the escape sequences for creating the coloured text.
At this point it gets a little more complicated. But with a little perseverance you can have your own customised and coloured account. The following are the escape sequences for creating the coloured text.


%{\e[1;31m%}
 
Red text
{| border="1" cellpadding="2"
%{\e[1;32m%}
!width="200"|Colour
Green text
!width="225"|Escape Sequence
%{\e[1;33m%}
|-
Yellow text
|Red text || %{\e[1;31m%}
%{\e[1;34m%}
|-
Blue text
|Green text || %{\e[1;32m%}
%{\e[1;35m%}
|-
Pink text
|Yellow text || %{\e[1;33m%}
%{\e[1;36m%}
|-
Cyan text
|Blue text || %{\e[1;34m%}
%{\e[1;37m%}
|-
Grey text
|Pink text || %{\e[1;35m%}
%{\e[1;38m%}
|-
Grey text
|Cyan text || %{\e[1;36m%}
%{\e[1;39m%}
|-
Grey text
|Grey text || %{\e[1;37m%}
%{\e[1;30m%}
|-
Dark grey text
|Grey text || %{\e[1;38m%}
%{\e[0m%}
|-
Back to normal
|Grey text || %{\e[1;39m%}
|-
|Dark grey text || %{\e[1;30m%}
|-
|Back to normal || %{\e[0m%}
|}
 


Here's the tricky part. These colour escapes sequences have to be printed to the prompt within the export command.  
Here's the tricky part. These colour escapes sequences have to be printed to the prompt within the export command.  
Line 117: Line 129:
  function userlist { reply=(`cat ~/.friends`); }  
  function userlist { reply=(`cat ~/.friends`); }  
  #generates a list of usernames from your .friends file
  #generates a list of usernames from your .friends file
 
 
  compctl -K userlist hey  
  compctl -K userlist hey  
  #adds this list of names to auto completion for the command "hey <username>"
  #adds this list of names to auto completion for the command "hey <username>"
Line 126: Line 138:




So say I'm the only person in your .friends file whose username begins with "c". Typing "ps -fU c<-TAB->" will auto-complete to "ps -fU cambo" (NB* this will also work for an alias of that command if you have one set). This can be convenient if you have a list of commands that you use on a regular basis for which aliases would be unsuitable.
So say I'm the only person in your .friends file whose username begins with "c". Typing "ps -fU r<-TAB->" will auto-complete to "ps -fU receive" (NB* this will also work for an alias of that command if you have one set). This can be convenient if you have a list of commands that you use on a regular basis for which aliases would be unsuitable.
zsh message (exporting ARGV0)
zsh message (exporting ARGV0)
== Removing the help message ==
Everytime you sign into redbrick, you get the help message. <br>
If you're tired of seeing this all you need to do is add a file called .nohelp in your home directory.  You can use the touch command to create a blank file.
receive@murphy (~) % touch .nohelp
== Customised zsh messages ==


You may have seen when you "spy" on another user's processes that they have a customised zsh message in the process list. More and more people do this as an added customisation (and annoyance ;)) to their account.
You may have seen when you "spy" on another user's processes that they have a customised zsh message in the process list. More and more people do this as an added customisation (and annoyance ;)) to their account.


  (~)[cambo@prodigy]>> ps -fU cambo
  receive@murphy (~) % ps -fU receive
  UID   PID  PPID  C   STIME   TTY     TIME CMD
UID       PID  PPID  C STIME TTY         TIME CMD
  cambo 25776 25774 0 10:01:56 pts/24    0:00 -zsh
  receive  2120  2118 0 Feb09 pts/212  00:00:01 -zsh
  cambo 19580 19569 0 23:35:58 pts/110  0:02 -zsh
  receive  16581  2120 0 02:00 pts/212 00:00:00 ps -fU receive
  root  5199 19580  0 10:08:16 pts/110  0:00 ps -fU cambo
 
  (~)[cambo@prodigy]>> ARGV0='Custom Message' exec zsh
  receive@murphy (~) % ARGV0='Custom Message' exec zsh
  (~)[cambo@prodigy]>>  ps -fU cambo
 
  UID   PID  PPID  C   STIME   TTY     TIME CMD
  receive@murphy (~) % ps -fU receive
  cambo 25776 25774 0 10:01:56 pts/24    0:00 -zsh
UID       PID  PPID  C STIME TTY         TIME CMD
cambo 19580 19569  0 23:35:58 pts/110  0:02 Custom Message
  receive  2120  2118 0 Feb09 pts/212  00:00:02 Custom Message
  root 5199 19580 0 10:08:16 pts/110  0:00 ps -fU cambo
  receive 22095 2120 0 02:06 pts/212  00:00:00 ps -fU receive
(~)[cambo@prodigy]>>


The command ARGV0='Custom Message' exec zsh changes the default message from -zsh to whatever you want. If you want this to be set everytime you login to redbrick, you can place the command in a file called .zlogin in your home directory. This file automatically gets sourced, when you exec a login session on the system.
The command ARGV0='Custom Message' exec zsh changes the default message from -zsh to whatever you want. If you want this to be set everytime you login to redbrick, you can place the command in a file called .zlogin in your home directory. This file automatically gets sourced, when you exec a login session on the system.
Line 159: Line 179:


If you have any problems or mess something up and need help, just talk to [[Helpdesk]].
If you have any problems or mess something up and need help, just talk to [[Helpdesk]].
[[Category:Helpdesk]]