Jump to content

Account Customisation (zsh): Difference between revisions

m
Line 117: Line 117:
  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 126:




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 c<-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)
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
  UID  PID  PPID  C    STIME  TTY    TIME CMD
cambo 25776 25774  0 10:01:56 pts/24    0:00 -zsh
cambo 19580 19569  0 23:35:58 pts/110  0:02 -zsh
root  5199 19580  0 10:08:16 pts/110  0:00 ps -fU cambo
(~)[cambo@prodigy]>> ARGV0='Custom Message' exec zsh
(~)[cambo@prodigy]>>  ps -fU cambo
  UID  PID  PPID  C    STIME  TTY    TIME CMD
cambo 25776 25774  0 10:01:56 pts/24    0:00 -zsh
cambo 19580 19569  0 23:35:58 pts/110  0:02 Custom Message 
root  5199  19580  0 10:08:16 pts/110  0:00 ps -fU cambo
(~)[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.
'''Be Careful:'''
If you are going to use a .zlogin file with the ARGV0 variable exported to something else, then you should take any commands from your .zshrc file, which print information to the screen and move them into your .zlogin instead. The reason for this is that when you log in, the system will:
* source your .zshrc
* source your .zlogin containing - ARGV0="" exec zsh
* source your .zshrc again - because of the exec zsh in .zlogin
If there were any commands in your .zshrc that printed to the screen, rbusers for example, then they would end up printing twice. So for any programs which you want to print to the command prompt at login. You should place them in your .zlogin.
Also be aware that resetting ARGV0 from its unset state will annoy some programs, most notably mv and cp, which will complain that the command is not of the right format. To get around this, do unset ARGV0, and then (if you must) reset the ARGV0 to its original value by either running ARGV0='Custom Message' exec zsh or sourcing your .zlogin file.
If you have any problems or mess something up and need help, just talk to [[Helpdesk]].