文章

Markdown代码识别

1. Linux中的配置文件

1.1 .bashrc 或 .bash_profile: bash

1
2
3
4
5
PS1="\n\[\033[01;36m\][\u@\h\[\033[01;32m\] \w\[\033[01;36m\]]\[\033[01;36m\] $(git_branch)\[\033[00m\]\n\\$\[\033[00m\] "
export HOMEBREW_PIP_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple #ckbrew
export HOMEBREW_API_DOMAIN=https://mirrors.tuna.tsinghua.edu.cn/homebrew-bottles/api  #ckbrew
export HOMEBREW_BOTTLE_DOMAIN=https://mirrors.aliyun.com/homebrew/homebrew-bottles #ckbrew
eval $(/opt/homebrew/bin/brew shellenv) #ckbrew

1.2 .vimrc: vim

1
2
3
4
5
set showtabline=0               " 隐藏顶部标签栏"
set guioptions-=r               " 隐藏右侧滚动条"
set guioptions-=L               " 隐藏左侧滚动条"
set guioptions-=b               " 隐藏底部滚动条"
set cursorline                  " 突出显示当前行"

1.3 各类 .conf 常用 ini 语言类型: ini

1
2
3
4
5
6
7
8
[mysqld]
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
datadir         = /var/lib/mysql
secure-file-priv= NULL
#skip-grant-tables
max_connections = 10000

2.代码类

2.1 C语言: c

1
2
3
4
5
6
#include <stdio.h>

int main() {
    printf("Hello, World!\n");
    return 0;
}

2.2 C++语言: cpp

1
2
3
4
5
6
#include <iostream>

int main() {
    std::cout << "Hello, World!" << std::endl;
    return 0;
}

2.3 Python语言: python

1
print("Hello, World!")

2.4 Ruby语言: ruby

1
puts "Hello, World!"

2.5 JavaScript (Node.js)语言: javascript

1
console.log("Hello, World!");

2.6 Java语言: java

1
2
3
4
5
public class HelloWorld {
    public static void main(String[] args) {
        System.out.println("Hello, World!");
    }
}

2.7 C#语言: csharp

1
2
3
4
5
6
7
using System;

class HelloWorld {
    static void Main() {
        Console.WriteLine("Hello, World!");
    }
}

2.8 Go语言: go

1
2
3
4
5
6
7
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}

2.9 Rust语言: rust

1
2
3
fn main() {
    println!("Hello, World!");
}

2.10 Swift语言: swift

1
print("Hello, World!")

2.11 Kotlin语言: kotlin

1
2
3
fun main() {
    println("Hello, World!")
}

2.12 PHP语言: php

1
2
3
<?php
    echo "Hello, World!";
?>

2.13 Bash语言: bash

1
echo "Hello, World!"

2.14 Jenkins Pipline语言: groovy

1
2
3
4
5
6
7
8
9
10
11
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                echo 'Building...'
            }
        }
    }
}

2.15 .jvm.options配置文件: propertiesbash

1
2
3
4
5
6
# 没有专门的语法高亮可以用 properties 或 bash
-Xms512m
-Xmx1024m
-XX:+UseG1GC
-XX:MaxGCPauseMillis=200

本文由作者按照 CC BY 4.0 进行授权