惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Y
Y Combinator Blog
Google DeepMind News
Google DeepMind News
腾讯CDC
V
Visual Studio Blog
Engineering at Meta
Engineering at Meta
博客园 - 司徒正美
小众软件
小众软件
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
T
Tailwind CSS Blog
Vercel News
Vercel News
爱范儿
爱范儿
Last Week in AI
Last Week in AI
G
Google Developers Blog
阮一峰的网络日志
阮一峰的网络日志
P
Proofpoint News Feed
有赞技术团队
有赞技术团队
D
DataBreaches.Net
博客园_首页
J
Java Code Geeks
云风的 BLOG
云风的 BLOG
V
V2EX
A
About on SuperTechFans
H
Hackread – Cybersecurity News, Data Breaches, AI and More
人人都是产品经理
人人都是产品经理

Ittavern.com

Wimage - Hosting Open-Source Image Uploader with Podman and external S3 Storage Switching from Hugo to picopaper Encryption using SSH Keys with age in Linux ETag in nginx - Simple Resource Caching Sending nginx Logs to Loki with Grafana Alloy How to: Cisco ISE backup to SFTP repository with public key authentication Dummy IP & MAC Addresses for Documentation & Sanitization Deploying ISSO Commenting System for Static Content using Docker Generate a Vanity v3 Hidden Service Onion Address with mkp224o ssh-audit Primer - Audit your SSH Server mtr - More Detailed Traceroute - Network Troubleshooting My Personal Backup Strategy - August 2024 iperf3 - User Authentication with Password and RSA Public Keypair Adding a trash can to Linux with trash-cli Bandwidth Measurement using netcat on Linux Getting started with rsync - Comprehensive Guide Cron Jobs on Linux - Comprehensive Guide with Examples SSH Server Hardening Guide v2 Port Knocking with knockd and Linux - Server Hardening Getting started with rclone - Data transmission Getting started with dig - DNS troubleshooting Getting started with Fail2Ban on Linux Getting started with netcat on Linux with examples URL explained - The Fundamentals Troubleshooting Asking The Right Questions Create tmux layouts using bash scripts Getting started with tcpdump - Ittavern.com Curl on Linux - Reference Guide Getting started with nmap scripts My Offsite Backup - March 2023
Linux - How to work with complex commands
2022-12-10 · via Ittavern.com

It can frustrate to work on complex commands in the terminal. I'll present you some tips on how to manage them. If you have another tip, I'd appreciate a quick message.

Use backslash\ to add a line break

This is fairly simple. Having one or multiple long lines with no structure can be messy and confusing. By adding \ for a line break adds more structure. A really simple example:

podman run -d --restart=always -p 127.0.0.1:3001:3001 -v /path/data:/app/data --name status.brrl.net docker.io/louislam/uptime-kuma:latest

With line breaks:

podman run -d \
  --restart=always \
  -p 127.0.0.1:3001:3001 \
  -v /path/data:/app/data \
  --name status.brrl.net \
  docker.io/louislam/uptime-kuma:latest

It is easier to read and work with, at least in my opinion.

Work on complex commands in your favorite $EDITOR #

I'lll show you now, how you can edit complex commands in your favorite CLI editor.

Enter command fc, or keep CTRL pressed and enter x and e as keyboard shortcut. This will open your default CLI editor. After finishing working on the command you want to run, simply 'save and close', and the command will run right after. I am going to show you how yo set your default editor at the end of the post.

The fc command is normally used to show the command history or re-edit already entered commands, but we can use it to work on complex commands. fc --help to find out more.

Set default editor in the CLI #

There are various ways to set the default editors, so you might have to look it up for your setup.

In general, it works to set the $EDITOR environment variable with the editor of choice. On most distros it should be 'nano', but you might prefer something else.

If we want to change our default editor to 'vim' temporarily, we can enter this command:

export EDITOR="/bin/vim"

You can double-check with:

echo $EDITOR or env | grep EDITOR

and

$EDITOR test.txt

Important: To change the default editor permanently, add export EDITOR="/bin/vim" to your .bashrc or whatever config file you use.

From now on, whenever you want to edit a command with fc, your favorite editor will open.