0%

Recently, when using an open source tool, I found a tool called tmux. Then I found that Tmux is quite popular, the repo star has 20K+, and my commonly used iTerm2 is also integrated with tmux. Based on this, it is necessary to understand tmux and clarify the usage scenarios.

Since the current use is still shallow, please point out if any mistakes

Concept

Start with the concept and understand its function.

tmux is a terminal multiplexer. It lets you switch easily between several programs in one terminal, detach them (they keep running in the background) and reattach them to a different terminal.

  1. Personal understanding is that tmux saves the terminal session on-site. For example, SSH is connected to a VPS, vi edits a file, directly closes the session, and then reopens the connection, you will find that the state is lost, you need to re-enter the target path and reopen it edit. With tmux, you can save this session, re-access the target machine, load the previously saved session, and everything will be restored as before.
  2. The reason why tmux can save sessions is because after tmux is installed on the target server, a separate service will be started for on-site saving.

Tmux Installation

Understand the above principles, you can understand that tmux is not necessarily installed locally, but installed on the machine that needs to save the session.

The installation commands in common operating system environments are as follows

1
2
3
4
5
# macOS
brew install tmux

# centos
yum install tmux
Read more »

Recently, I spent some time trying out the remote development tools from VSC and JB and found them quite good. Here’s a brief introduction.

Now, high-cost compilation problems at work can be handled by remote machines. Of course, for smooth operation, remote machines and network conditions still have high requirements.

Visual Studio Code

To achieve remote development with VSC, the following steps are needed:

  1. Deploy Code Server
  2. Install Visual Studio Code, a.k.a. VSC, locally
  3. Install the Visual Studio Code Remote - SSH plugin
  4. Add SSH configuration information and connect

JetBrains

For remote development, JB requires the local installation of the client JetBrains Gateway.

  1. Install JetBrains Gateway locally
  2. Start it, fill in the server address, port, etc.
  3. Choose the server IDE to be installed as needed, like I chose WebStorm here
  4. Select the project you want to open

For server needs like Git projects, you can operate directly through the command line by opening the terminal in the IDE.

Note

  • Currently, Gateway is still in Beta version, and compared to VSC’s solution, it’s not as stable.
  • Gateway reads the plugin settings of the local JB account’s corresponding IDE and then synchronizes them to the server IDE, so the experience of shortcuts remains consistent.

Conclusion

Gradually moving cumbersome projects to the server lightens the local workload.

Now many site services have a 2FA mechanism, and services such as login or online payment need to send a text message. Enter the verification code after receiving the text message.

In response to this mechanism, the iPhone supports automatic extraction, which can be filled by clicking, while on the Mac, only Safari has a similar experience. If you use other apps such as Chrome, you will lose this experience. In order to solve this deficiency, a workflow is developed here to optimize the experience.

Download Link:Click Here

Effect

As above, wait for dozens of seconds after sending the message, when the text message is received, enter 2fa to evoke the workflow, select the verification code item, and press Enter to copy to clipboard
board, ⌘ + v fills the target input box.

Notice

  1. There are differences in the validity period of different verification codes, so workflow provides the option to set the validity period. By default, the SMS verification code received within 10 minutes is queried.

  2. In order to read text messages on Mac, Alfred needs to have disk access permissions

    Read more »

The Alfred sdk has been packaged before. The way to use it is to manually install the package in the specific workflow js, and then require the corresponding module. The commonly used script filter construction, screening, and quicklook have encapsulated fn, which is easy to use. But there is no CLI support yet. In order to further improve efficiency, the development of CLI can be driven out. Mark it here for a little experience.

Solve pain points

  1. Use the CLI to automatically install the Alfred SDK package
  2. Generate default or specified JS files, and module loading is also built-in at the code level, which does not need to be written manually.

In this way, you only need npx @stacker/alfred-utils init , and then open index.js to write for business.

Read more »

Recently, a community project received a request for users to connect an external camera to their Mac, hoping that Alfred would support one-click switching between different cameras. Because there is a rarely need to open video, I haven’t noticed how to use an external device on a Mac before, so I try it here.

Camera Installation

I remembered that I once bought a Logitech Webcam C110, so I found it and tried it, USB interface, I converted the connection through the docking station USB=>TypeC, then opened Tencent Meeting or Facetime, and can see the plug in the camera options of new equipment. Select Discovery work.

After trying, I found a few problems

  1. The settings such as default camera/disabling a camera can‘t be selected in the Apple Settings Center.
  2. It can only be set correspondingly in the app that uses the camera, such as Tencent Meeting, and the setting can’t be shared.

Used scenarios

At home, I often run my Mac in host mode. In host mode, mic/camera is unavailable. At this time, if there is a video demand, the value of an external camera will appear, and the camera quality of the Mac is not so good as well.

Support Alfred

After solving how to use the external camera, looking back at the efficiency plug-in support of netizens, the Mac GUI must have a setting place, or the terminal/command has corresponding support.

I found that through the command system_profiler SPCameraDataType -json that comes with the Mac after searching material, I can get all the camera devices connected to the Mac, but script control to open a camera is not supported, therefore it is impossible to switch cameras with one key in Alfred.

Finally, the conclusion is that the camera list can be displayed, but the specific operation to open a camera is not work.

Write at the End

  • When the Mac is turn off, the external camera still needs to be operated in a specific app. At present, there is no way to solve this automatically.

It has been a few months since Alfred launched Universal Action, and I have become accustomed to using it to solve demands of some scenarios. Here is a summary of the role that action plays in my efficient use.

Position of Universal Action

Here, let’s talk about the difference between this interaction method and the keywords and hotkey scenarios provided by Alfred before.

Main Difference

The fundamental difference between Universal Action and the previous scene is the difference in trigger conditions. The trigger condition of Universal Action is that you select any element [file/link/text], and execute an action based on such an input value. For example, you can select a piece of text, automatically send Twitter, send emails, select a URL to automatically open browser links, etc., and the previous scene is your direct keyword or hotkey. So the difference is mainly here.

Therefore, when there is a certain requirement, you only need to consider what the interaction scenario is, and then choose an appropriate way to solve it.

Position

Universal Action can be used to perform an operation based on an element [file/link/text]

Common Points

The essence is workflow. For example, if you develop it yourself, you will create a workflow. The main difference is that the interaction/triggering method is different.

Common Action Sharing

If you can’t fully understand, please check below example:

  1. String Manipulation by yourself

    • Sometimes if you want to change the format of the selected text, such as Pascal, kebab, upper snake, etc. At this time, I only need to select the target text, ⌘\ to evoke, select the corresponding action and press Enter to modify successfully

    • If it is a commonly used editor, it generally has this feat, but considering the scenarios without IDE, such as browsers, this is still in demand

      Download address

  2. Open with built-in

    • Sometimes I want to personalize the open app in a certain format, such as PDF, I don’t want to use preview, so I can wake up, select Open with, and then select the target app and press Enter
  • Note that Open with only changes the open app this time, it is not permanent. If you need to change the open app of a certain file type, you need to modify the default open app in the file details

Hotkey Setting

My hotkeys are set as follows

  • Alfred’s hotkey is ⌘ double tap i.e. double tap ⌘
  • The hotkey for Universal Action is ⌘\

Consideration points: Both types of triggers belong to Alfred, so the hotkey settings are close, and ⌘ is the modifier key used in high frequency

Write at the End

  • I haven’t written an Alfred user guide for a long time, because the efficiency workflow that conforms to my habits has been polished through continuous use, and there are not many new things.
  • I didn’t think Universal Action is useful to me from the beginning, but after trying it a few times, I gradually realized that it still has certain usage scenarios, so you still need to try to use it for new things, otherwise you may lose the opportunity to improve

References

I really like the sense of achievement obtained by open source projects. In the past year, I have insisted on doing several open source projects, and I have also gained some stars from netizens, some also add WeChat, raise requirements, the charm of open source is here.

For example, if someone stars your project, it would be better to be able to receive telegram notifications in time, because the NPM package release notification has been done before, so this is easy to do, but because there are still some pitfalls, so mark here, maybe help some friends.

Configuration

1
2
3
4
5
6
7
8
9
10
env:
REPO_NAME: ${{ github.event.repository.name }}
steps:
- name: Notify
uses: appleboy/telegram-action@master
with:
to: ${{ secrets.TELEGRAM_TO }}
token: ${{ secrets.TELEGRAM_TOKEN }}
message: Someone stars **${{env.REPO_NAME}}** repository, see [here](https://github.com/${{github.repository}}).
format: markdown

Full Configuration click here

Configuration Instructions

GitHub Action中的变量有很多中,${{ github.event.repository.name }}${{github.repository}}为上下文环境变量,这个不需要配置,直接使用,${{ secrets.TELEGRAM_TO }}为仓库配置变量,需要在仓库设置中设定。

There are many variables in GitHub Action, ${{ github.event.repository.name }}, ${{github.repository}} are context variables, which do not need to be configured, use directly, ${ { secrets.TELEGRAM_TO }} is a warehouse configuration variable, which needs to be set in the warehouse settings.

GITHUB_SERVER_URL is not Worked?

The official website has said that the default environment variable is $GITHUB_SERVER_URL, and the usage method is $GITHUB_SERVER_URL, but if it is written in the above message, it will not work, the reason is that the environment variable is used when using the shell, if it is a job The github context needs to be used in the step

Telegram Configuration Parameter Acquisition

  • TELEGRAM_TOKEN
    • Through @BotFather, create a Bot to obtain, note that the complete format of the Token will be like this 12345678:BBFntuCD6nRx1ZIYZ-eCyfP1UO4FeAjnz2M
  • TELEGRAM_TO
    • Need to send a message to the bot, make sure chat is turned on

    • Visit https://api.telegram.org/bot$TELEGRAM_TOKEN/getUpdates to get the chatID in it

Write at the End

As above, you can realize the telegram notification, start!

I love Alfred so much that once I find one of my efficiency needs, I will study the feasibility of Alfred. If it is feasible, I will immediately find a third-party or my own custom development. Until today, I have developed 16 workflows, and there are also many experience posts, so proud of myself.

Whether it is self-developed or third-party, most of them are used frequently in my daily life. Share here, maybe I can help some friends.

Notice

Click the workflow title link to access the download page. The download page will have an introduction, so I won’t go into details here, just show the main functions with GIF animation

Workflows

  1. Airdrop

  2. Currency Converter

  3. Dash

  4. Eudic Tools

  5. GitHub

  6. JetBrains - Open Project - v3

  7. New File

  8. OCR

  9. Pic Uploader

  10. Surge

  11. Switch Sound Output

  12. 印象笔记

Write at the End

  • Efficiency tools are not the best, just fit
  • In the actual installation and use, there may be tracks, there are the following solutions
    • Here, I maintain a lot of issues that I have encountered in actual use Click here to search if there are related problems, and welcome to raise issues
    • Ask questions on the download page of the above workflow, enthusiastic community enthusiasts or authors will reply

img

I have always liked to use Alfred’s Snippet to input commonly used text blocks, and also support configure some parameters, which can usually save the time of inputting repeated text. For example, we often did CR before and we needed a simple summary at the end. In order to improve the efficiency of the summary, I made a Snippet.

But the downside of Snippet is that Alfred only exists on MacOS, and I am unhappy as an Apple user. Because the Apple system itself has text replacement function, I had to place a part of the text block in the system layer configuration, so that it can be supported across Apple devices. However, if use the two at the same time, will cause issues. So I thought about the cooperation between the two, and marked it here.

Alfred Snippet vs Apple Text Replacement

First, let’s sort out the differences between the two.

  1. Platform limitations

    • Alfred only supports Mac, there is no iOS version. There is a remote App, but the essence is only to remotely control some functions of the Mac version App, not a real iOS ported version
    • Apple’s text replacement will be synchronized to each device using iCloud, and once modified, all devices can be used immediately
  2. Functional limitations

    • Alfred’s Snippet itself supports various variables. In addition, it can use workflow to achieve more powerful replacement, and it can also control the position of the final cursor. In a word, it is powerful
    • Apple’s text replacement is relatively simple, just replace between strings
    • On the Mac system, text replacement in EN state does not work in all apps, such as MacDown, or the address bar of Chrome, but the above apps work in Chinese. Comparing devices, such as iPhone and iPad, work both in EN and Chinese. It is estimated that there is an App adaptation problem with text replacement.

Uniform convention

text prefix

Although text replacement is good, if the text itself has no features, it will often be accidentally triggered in actual high-frequency input. In order to solve this problem, it is necessary to formulate a prefix, here I use t, such as codereview, it will be tcodeview.

There are some considerations for this

  1. Letters are better than special symbols

    Because this text replacement scheme is often used in the iPhone, and the layout of the mobile phone keyboard determines the letter prefix, the text replacement can be quickly implemented without switching the keyboard, which is more efficient.

  2. t means text, better associative memory, friendly

Text Phrase Division

  • As mentioned above, Alfred does not cross terminals, so for daily simple text phrases, such as mobile phone number, home address, email and other high-frequency input simple text, configure it at the Apple system level
  • For complex ones used at work and mainly solved on the desktop side, configure in Alfred

Effect

Alfred Snippet

Apple Text Replacement

Write at the End

Constantly polishing tools, high efficiency is the king

Because of the large-screen display at home, I likes to use the host mode without using the screen on Mac. But note that if Mac is on closed-display mode, the mic of the Mac itself is not available, and the speakers can still be used normally. If you want to use the mic normally, just switch to the headset, but if you don’t want to use the headset, then the question is, how to connect the mic?

Buy Mic and Headphone Adapter Cable

The cost is listed as below:

  1. Asphan (XFAN) D1 set top microphone 153RMB
  2. UGREEN headphone and microphone one-to-two transfer cable 21RMB

Installnation

Notice

  • If you see that the Mac recognizes the external mic normally, the connection is successful As shown above
  • To use XFAN’s camera cable that is two-level cable to connect to the mic input of the UGREEN adapter cable
  • Although I have not connected the headset here, but you can see the external headset in the Mac-sound-input device, just ignore it
  • I saw some introductions on the Internet that it is necessary to ensure that the headphones with the adapter cable also need to be connected to ensure that the Mac can detect the external mic normally. After testing, it is not necessary

Fixed on table

Since I am using it on a desktop Mac, it needs to be fixed.

The following two schemes can be used after try

  • Blue Butadiene solved
  • Mini portable tripod with 1/4 screw

Currently I use option 1

Write at the End

After simple settings as above

  • On closed-display mode, you can use the Mac’s built-in speaker + external mic, nice!

  • Of course, you can also use an external speaker such as HomePod alone, which is flexible.