Skip to content

Instantly share code, notes, and snippets.

Linux 命令行编辑快捷键

初学者在Linux命令窗口(终端)敲命令时,肯定觉得通过输入一串一串的字符的方式来控制计算是效率很低。 但是Linux命令解释器(Shell)是有很多快捷键的,熟练掌握可以极大的提高操作效率。 下面列出最常用的快捷键,这还不是完全版。

  • 命令行快捷键:
    • 常用:
      • Ctrl L :清屏
  • Ctrl M :等效于回车
@k8scat
k8scat / Makefile
Created November 21, 2022 18:14 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
# What to do when mysqldump fails
function report_mysqldump_fail() {
cat $scratch/${filename}_raw.err >> $log
mailx -s "mysqldump failed for DB $db_name on $HOSTNAME!!!" emailme@none.com < $log
exit 2
}
# How to report a step along the process
function status_report() {
message=$1
@k8scat
k8scat / github.js
Last active February 24, 2022 02:41 — forked from ye11ow/github.js
Add a "Copy link" button to Github issue and pull requests
// ==UserScript==
// @name Copy Link for GitHub Issues and PRs
// @namespace http://tampermonkey.net/
// @version 0.2
// @description Add a "Copy link" button to Github issue and pull requests
// @author ye11ow, K8sCat <k8scat@gmail.com>
// @match https://github.com/*
// @include https://github.com/*/issues/*
// @include https://github.com/*/pull/*
// @icon https://www.google.com/s2/favicons?domain=github.com
@k8scat
k8scat / gist:213820c0204f452d5c67295c406b78fd
Created January 9, 2022 13:05 — forked from cdown/gist:1163649
Bash urlencode and urldecode
urlencode() {
# urlencode <string>
old_lc_collate=$LC_COLLATE
LC_COLLATE=C
local length="${#1}"
for (( i = 0; i < length; i++ )); do
local c="${1:$i:1}"
case $c in
@k8scat
k8scat / openresty.service
Created June 9, 2021 02:52 — forked from HauptJ/openresty.service
OpenResty Systemd service file
# Stop dance for OpenResty
# A modification of the Nginx systemd script
# Source: https://www.digitalocean.com/community/tutorials/how-to-use-the-openresty-web-framework-for-nginx-on-ubuntu-16-04
# =======================
#
# ExecStop sends SIGSTOP (graceful stop) to the Nginx process.
# If, after 5s (--retry QUIT/5) OpenResty is still running, systemd takes control
# and sends SIGTERM (fast shutdown) to the main process.
# After another 5s (TimeoutStopSec=5), and if OpenResty is alive, systemd sends
# SIGKILL to all the remaining processes in the process group (KillMode=mixed).
@k8scat
k8scat / gh-dl-release
Created June 6, 2021 18:27 — forked from maxim/gh-dl-release
Download assets from private Github releases
#!/usr/bin/env bash
#
# gh-dl-release! It works!
#
# This script downloads an asset from latest or specific Github release of a
# private repo. Feel free to extract more of the variables into command line
# parameters.
#
# PREREQUISITES
#
#!/bin/bash
# bash generate random alphanumeric string
#
# bash generate random 32 character alphanumeric string (upper and lowercase) and
NEW_UUID=$(cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1)
# bash generate random 32 character alphanumeric string (lowercase only)
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1
@k8scat
k8scat / ssl_smtp_example.go
Created May 19, 2021 07:54 — forked from chrisgillis/ssl_smtp_example.go
Golang SSL SMTP Example
package main
import (
"fmt"
"log"
"net"
"net/mail"
"net/smtp"
"crypto/tls"
)
@k8scat
k8scat / rm_mysql.md
Created May 17, 2021 14:31 — forked from vitorbritto/rm_mysql.md
Remove MySQL completely from Mac OSX

Remove MySQL completely

  1. Open the Terminal

  2. Use mysqldump to backup your databases

  3. Check for MySQL processes with: ps -ax | grep mysql

  4. Stop and kill any MySQL processes

  5. Analyze MySQL on HomeBrew:

    brew remove mysql