04 - configure shortcut key to start terminal / terminal beautification

1, Configure startup terminal shortcut command:

1. Turn on automatic operation

 

  2. Select quick operation

  3. Set "workflow received" to "no input"; Then drag run AppleScript on the left to the right

  4. Replace the following code at the code on the right. The code opens the terminal on the desktop and the path is~

You can click "run" to check whether it can be executed successfully. After adding the following codes, you can open the terminal at any position

on run {input, parameters}
    tell application "Finder"
        set myWin to window 1
        set thePath to (quoted form of POSIX path of (target of myWin as alias))
        if application "Terminal" is running then
            tell application "Terminal"
                do script "cd " & thePath
                activate
            end tell
        else
            tell application "Terminal"
                do script "cd " & thePath in window 1
                activate
            end tell
        end if
    end tell
end run

 

  5. After saving, it can be named "open terminal"

Then open system preferences - > keyboard - > shortcut keys

Select the service on the left, find the file just named in the general place on the right, and then set your favorite shortcut key

  Then you can press the shortcut key set anywhere to open the terminal ~

  2, Beautification terminal

There are many types of shell s. Bash is the default under mac and linux. Although bash has powerful functions, bash's prompt function is not powerful enough and the interface is not dazzling enough for programmers with laziness as their virtue. It is not an ideal tool. zsh is extremely powerful. It has all the functions that bash does not have.

If zsh is not installed, install it and then switch(   After switching, the user needs to log out and log in again  )

# Installing zsh
brew install zsh

  Switch shell to zsh:

chsh - s /bin/zsh

1. Download and install iTerm2   Mac artifact iTerm2 basic commands

2. Install ohmyzsh. Generally, wget is installed on the Mac. If it is not installed, install wget first:

brew install wget

Installation ohmyzsh instructions:

sh -c "$(wget https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh -O -)"

**Error 1: **ohmyzsh report "ensure completion dependent directories detected" error

Permission issues:

chmod 755 /usr/local/share/zsh

chmod 755 /usr/local/share/zsh/site-functions

Just.

**Error 2: **chsh - s /bin/zsh, always prompt chsh: no changes made error

Prompt chsh:no changes made solution: terminal input:

**dscl . -read /Users/$USER/ UserShell**

**exec su - $USER**

Then enter the password. Perfect solution

appear:

  ____  / /_     ____ ___  __  __   ____  _____/ /_  
 / __ \/ __ \   / __ `__ \/ / / /  /_  / / ___/ __ \ 
/ /_/ / / / /  / / / / / / /_/ /    / /_(__  ) / / / 
\____/_/ /_/  /_/ /_/ /_/\__, /    /___/____/_/ /_/  
                        /____/                       ....is now installed!
Please look over the ~/.zshrc file to select plugins, themes, and options.

p.s. Follow us at https://twitter.com/ohmyzsh.

p.p.s. Get stickers and t-shirts at http://shop.planetargon.com.

It means that the installation is successful. At this time, when you open the terminal, you can already see the highlight

3. Install ohmyzsh additional plug-ins:

Install the history command prompt plug-in:

git clone git://github.com/zsh-users/zsh-autosuggestions $ZSH_CUSTOM/plugins/zsh-autosuggestions

Install the highlight plug-in

git clone git://github.com/zsh-users/zsh-syntax-highlighting $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

4. Add source ~/.bash_profile

zsh loads ~ /. zshrc by default. If user environment variables are not loaded by default, a line needs to be added in ~ /. zshrc

 source ~/.bash_profile

After that, the user environment variables will be loaded every time the console window is started

5. Change the theme, font, etc

 

  6. Set oh-my-zsh theme   More topics

#Modify theme
vim ~/.zshrc

Change ZSH_THEME to:   AF magic theme (with split lines)

 

  7. After modification, finally update the configuration

# Update configuration
source ~/.zshrc

  Effect display:

 

 

 

Posted by jackliu97 on Wed, 10 Nov 2021 05:24:23 -0800