FreeBSD Manual Pages
man(1) switchBashZsh man page man(1) NAME switchBashZsh - Portable shell switching between Bash and Zsh SYNOPSIS switchBashZsh - setup a portable shell environment that you can reuse across Bash/Zsh and across multiple operating systems: (FreeBSD/Linux/Cygwin) DESCRIPTION switchBashZsh is a convenient way of setting up and then reusing your master shell environment when you work with Bash or Zsh. It works across all major Open Source implementations (FreeBSD / Linux / Cyg- win). When you run the setup script, it just creates the filesystem layout it needs. If you later switch your shell from Bash to Zsh or vice versa, the layout ensures that your new shell works just as the prior one. When you use switchBashZsh the first time (to create your master shell environment), the major facilities are the aliases A (edit your aliases) and AA (insert your aliases into the shell environment). Aliases are stored under ~/.shell/aliases. Similar hacks exist for exports (E/EE), functions (F/FF), commands to auto-execute on login, a.k.a. 'uponlogin' (I/II) and commands to auto- execute on logout, a.k.a. 'uponlogout' (O/OO). The first time you use switchBashZsh, you have to do the hard work in setting up your complete shell environment. But once you have done the hard work, you can get the same environment every time in future with very little effort - just run switchBashZsh setup script, and copy over your master ~/.shell directory (or maybe even modify the switchBashZsh script). It is nice to know a bit about the layout utilized by switchBashZsh. ~/.bashrc is hard-linked as ~/.bash_profile ~/.zshrc and ~/.bashrc source a common file ~/.shellrc When using switchBashZsh, do not modify .bashrc / .bash_profile / .zshrc yourself. Instead, modify the tree under ~/.shell (see below). ~/.shellrc uses the following tree in which the symbolic links level_2 and level_3 get populated dynamically at the time of login. (Linux systems use level_2 & level_3. FreeBSD/Cygwin use level_2 only.) ~/.shell |-- aliases |-- exports |-- functions |-- uponlogin |-- uponlogout |-- level_1.all |-- level_2 -> ? |-- level_2.cygwin |-- level_2.freebsd |-- level_2.linux |-- level_3 -> ? |-- level_3.arch |-- level_3.debian |-- level_3.redhat The following utility aliases are available in a switchBashZsh instal- lation: alias editor="$EDITOR" alias A="editor ~/.shell/aliases" alias AA=". ~/.shell/aliases" alias E="editor ~/.shell/exports" alias EE=". ~/.shell/exports" alias F="editor ~/.shell/functions" alias FF=". ~/.shell/functions" alias I="editor ~/.shell/uponlogin" alias II=". ~/.shell/uponlogin" alias O="editor ~/.shell/uponlogout" alias OO=". ~/.shell/uponlogout" alias L1="editor ~/.shell/level_1.all" alias L2="editor ~/.shell/level_2" alias L3="editor ~/.shell/level_3" # only for Linux While it should not be difficult to commit all the above hacks to mem- ory, at least remember the three most important ones: A Edit portable aliases AA Insert portable aliases into the shell environment L2 Edit OS-specific definitions (aliases/exports/functions) When using switchBashZsh, remember that something is considered imple- mentation-independent (and thus fully portable) if it works the same across FreeBSD / Linux / Cygwin. <alias su="su - toor"> is a FreeBSD implementation-dependent alias because it won't work on Cygwin and Linux, where the toor user does not exist. With the above in mind : 1) Put commands to be auto-executed upon login in ~/.shell/uponlogin and commands to be auto-executed upon logout in ~/.shell/uponlogout 2) Put all OS-independent aliases in ~/.shell/aliases 3) Put all OS-independent exports in ~/.shell/exports 4) Put all OS-independent functions in ~/.shell/functions 5) Place all OS-dependent definitions ~/.shell/level_2 If you have any definition that depends not just on the OS but further on its flavours, place it under ~/.shell/level_3. So if you are on a Linux box and are working with a definition that is distro-dependent (eg: an alias to <list all installed packages>), place the definition under ~/.shell/level_3, not ~/.shell/level_2. ~/.shell/level_2 is re- served for stuff that works on the OS without concern for its flavours. OPTIONS switchBashZsh does not accept any arguments, except '--help' - which brings up this man page. SEE ALSO env(1) Running the bare command `alias` displays all aliases active. `man alias` should work too, but is currently unusable because it redi- rects as a shell built-in. BUGS/LIMITATIONS 1) Default (level_3) yum alias definitions are CentOS-based and may not always work out-of-the-box under RedHat distributions. If so, just use L3 to edit those aliases. AUTHOR Manish Jain (bourne.identity@hotmail.com) 1.3 20 April, 2021 man(1)
NAME | SYNOPSIS | DESCRIPTION | OPTIONS | SEE ALSO | BUGS/LIMITATIONS | AUTHOR
Want to link to this manual page? Use this URL:
<https://man.freebsd.org/cgi/man.cgi?query=switchBashZsh&sektion=1&manpath=FreeBSD+Ports+15.0>
