pages tagged shell http://meng6net.localhost/tag/shell/ <p><small>Copyright © 2005-2020 by <code>Meng Lu &lt;lumeng3@gmail.com&gt;</code></small></p> Meng Lu's home page ikiwiki Tue, 16 May 2017 23:59:39 +0000 Installing and configuring Zsh http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_zsh/ http://meng6net.localhost/computing/installing_and_configuring/installing_and_configuring_zsh/ bash computing configuration documentation installation note shell software zsh Tue, 16 May 2017 23:59:39 +0000 2017-05-16T23:59:39Z <h2>Install</h2> <p>On macOS, install with Homebrew:</p> <pre><code>brew install zsh </code></pre> <p>On Ubuntu Linux:</p> <pre><code>sudo apt-get install zsh </code></pre> <h2>Initial configuration</h2> <p>Type <code>zsh</code> and then follow the prompt to configuration zsh</p> <pre> <code>This is the Z Shell configuration function for new users, zsh-newuser-install. You are seeing this message because you have no zsh startup files (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory ~). This function can help you with a few settings that should make your use of the shell easier. You can: (q) Quit and do nothing. The function will be run again next time. (0) Exit, creating the file ~/.zshrc containing just a comment. That will prevent this function being run again. (1) Continue to the main menu. --- Type one of the keys in parentheses --- 1 Attempting to extract information from manual pages... Please pick one of the following options: (1) Configure settings for history, i.e. command lines remembered and saved by the shell. (Recommended.) (2) Configure the new completion system. (Recommended.) (3) Configure how keys behave when editing command lines. (Recommended.) (4) Pick some of the more common shell options. These are simple "on" or "off" switches controlling the shell's features. (0) Exit, creating a blank ~/.zshrc file. (a) Abort all settings and start from scratch. Note this will overwrite any settings from zsh-newuser-install already in the startup file. It will not alter any of your other settings, however. (q) Quit and do nothing else. The function will be run again next time. --- Type one of the keys in parentheses --- </code></pre> <h2>Install Prezto</h2> <p><a href="https://github.com/sorin-ionescu/prezto">Presto</a> is a configuration framework for Zsh.</p> <ol> <li> <p>Launch Zsh:</p> <pre><code> zsh </code></pre></li> <li> <p>Clone the repository:</p> <pre> <code> git clone --recursive https://github.com/sorin-ionescu/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" </code></pre> <p>If installing the 'paradox' prompt theme:</p> <pre> <code> git clone --recursive https://github.com/paradox460/prezto.git "${ZDOTDIR:-$HOME}/.zprezto" </code></pre></li> <li> <p>Create a new Zsh configuration by copying the Zsh configuration files provided:</p> <pre><code> setopt EXTENDED_GLOB for rcfile in "${ZDOTDIR:-$HOME}"/.zprezto/runcoms/^README.md(.N); do ln -s "$rcfile" "${ZDOTDIR:-$HOME}/.${rcfile:t}" done </code></pre> <p>If it gives any warnings, you may need to remove the previously existing configuration files <code>.zsh*</code> and <code>.prezto*</code>.</p> </li> <li> <p>Set Zsh as your default shell:</p> </li> </ol> <p>Use the "default" zsh:</p> <pre><code> chsh -s /bin/zsh </code></pre> <p>If on macOS and if <code>zsh</code> was installed using Homebrew as <code>/usr/local/bin/zsh</code>:</p> <pre><code> chsh -s /usr/local/bin/zsh </code></pre> <p>does not actually work. Use System Preferences &gt; Users &amp; Groups &gt; unlock, select the user, right click and open "Advanced Options...", change shell to <code>/usr/local/bin/zsh</code>.</p> <p>References: * http://superuser.com/questions/362372/change-the-login-shell-of-mac-os-x-lion-from-bash-to-zsh * http://osxdaily.com/2012/03/21/change-shell-mac-os-x/. * http://stackoverflow.com/questions/3327013/how-to-determine-the-current-shell-im-working-on</p> <ol> <li>Open a new Zsh terminal window or tab.</li> </ol> <h2>Customize command prompt</h2> <p>http://www.paradox.io/posts/9-my-new-zsh-prompt</p> <h2>Modularizing <code>.bashrc</code> and <code>.zshrc</code></h2> <pre><code>meng  ~  ls -la /home/meng/.bashrc* -rw-r--r-- 1 meng 3823 Jan 27 19:05 /home/meng/.bashrc lrwxrwxrwx 1 meng 85 Jan 27 19:13 /home/meng/.bashrc_meng -&gt; /home/meng/Dropbox/WorkSpace/Computing/ConfigurationFiles/Bash/.bashrc_meng* lrwxrwxrwx 1 meng 84 Jan 27 19:13 /home/meng/.bashrc_all -&gt; /home/meng/Dropbox/WorkSpace/Computing/ConfigurationFiles/Bash/.bashrc_all lrwxrwxrwx 1 meng 86 Jan 27 19:13 /home/meng/.bashrc_linux -&gt; /home/meng/Dropbox/WorkSpace/Computing/ConfigurationFiles/Bash/.bashrc_linux lrwxrwxrwx 1 meng 93 May 10 22:53 /home/meng/.bashrc_mengmaclaplx -&gt; /home/meng/Dropbox/WorkSpace/Computing/ConfigurationFiles/Bash/.bashrc_mengmaclaplx lrwxrwxrwx 1 meng 91 May 11 17:34 /home/meng/.bashrc-zshrc_main -&gt; /home/meng/Dropbox/WorkSpace/Computing/ConfigurationFiles/Bash/.bashrc-zshrc_main meng  ~  ls -la ~/.zshrc* lrwxrwxrwx 1 meng 35 May 10 16:45 /home/meng/.zshrc -&gt; /home/meng/.zprezto/runcoms/zshrc lrwxrwxrwx 1 meng 83 May 10 18:47 /home/meng/.zshrc_meng -&gt; /home/meng/Dropbox/WorkSpace/Computing/ConfigurationFiles/Zsh/.zshrc_meng </code></pre> <p>Depending on if Bash or Zsh is used, either <code>.bashrc</code> is loaded which in turn loads <code>.bashrc_meng</code> or <code>.zshrc</code> is loaded which in turn loads <code>.zshrc_meng</code>.</p> <p><code>.bashrc_meng</code> and <code>.zshrc_meng</code> loads the main entry file <code>.bashrc-zshrc_main</code> which loads other smaller OS-dependent and computer-dependent configuration files.</p> <h2>References</h2> <ul> <li><a href="http://www.bash2zsh.com/zsh_refcard/refcard.pdf">Zsh reference card</a></li> <li><a href="http://www.bash2zsh.com/">From Bash to Zsh</a></li> </ul>