跳转至

${toc}

常见配置拾遗

neovim

安装 neovim

for ubuntu

sudo apt install software-properties-common -y
sudo add-apt-repository ppa:neovim-ppa/stable -
sudo add-apt-repository ppa:neovim-ppa/unstable -y
sudo apt-get update
sudo apt install neovim -y

neovim 自动补全

自动补全触发的逻辑

首先在coc中,推荐的配置是用 tab 选择补全,用cr or 确认选择 也可以配置成使用方向键选择补全,用tab进行确认,跳转

而由于在 utilsnippets 中 用于触发补全的键是 tab, 和coc的快捷键冲突了 所以tab切换无效,我们可以在 vimrc 中将 util snippets 的触发改成c-e 这样大家就不互相干扰,各玩各的。

为snippets增加数学环境

在snippets文件 最开始的地方加上

global !p
def math():
    return vim.eval('vimtex#syntax#in_mathzone()') == '1'

def comment(): 
    return vim.eval('vimtex#syntax#in_comment()') == '1'

def env(name):
    [x,y] = vim.eval("vimtex#env#is_inside('" + name + "')") 
    return x != '0' and x != '0'
endglobal

snippets 的组成

tutorial

symbol meaning
w expand on word boundaries
A automaticaly expanding
<++>

再给属于 数学环境下的snippets 头上加 context “math()”

配置 lsp

coc-nvim-lsp

c / c++

  • install clangd sudo apt install clangd Then
  • add coc-clangd or
  • config language server in cocconfig.json

java

  • add coc-java in g:coc\_global\_extensions list
  • install open-jdk (version >= 17)
 apt-cache search openjdk | egrep '11|17|18'
 apt update
 apt install openjdk-17-jdk

rust

cargo

very simple

  • install rust itself website curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
  • add coc-rust-analyzer in g:coc\_global\_extensions list
  • some tutorial offical tutorial

go

  • install go itself website
  • install gopls
    1. export GO111MODULE=on
    2. go env -w GOPROXY=https://goproxy.cn,direct 切换为国内代理
    3. go install golang.org/x/tools/gopls@latest 下载 gopls
    4. set up languageserver in cocConfig, remember write absolute path for gopls
  • begin writing code
go mod init example/hello
cd example/hello
touch hello.go
package main

import "fmt"

func main() {
    fmt.Println("Hello, World!")
}
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.19.4.linux-amd64.tar.gz
  • add coc-rust-analyzer in g:coc\_global\_extensions list

haskell

  • first install ghcup, website

    after installing, may need to add ghcup to your environment variable. export PATH=$PATH: ...

  • using ghcup to install hls, website
  • Then add configrations in cocConfig.json
    "haskell": {
            "command": "haskell-language-server-wrapper",
            "args": ["--lsp"],
            "rootPatterns": ["*.cabal", "stack.yaml", "cabal.project", "package.yaml", "hie.yaml"],
            "filetypes": ["haskell", "lhaskell"],
            // Settings are optional, here are some example values
            "settings": {
                "haskell": {
                    "checkParents": "CheckOnSave",
                    "checkProject": true,
                    "maxCompletions": 40,
                    "formattingProvider": "ormolu",
                    "plugin": {
                        "stan": { "globalOn": true }
                    }
                }
            }
        },

kotlin

  1. download kotlin lsp at github
  2. add configrations
    "languageserver": {
      "kotlin": {
        "command": "~/lsp/kotlin/server/bin/kotlin-language-server",
        "filetypes": ["kotlin"]
      }
    }
    
  3. install kotlin via sdk

  4. 下载 kotlin tutorial

    注意使用 curl -s "https://get.sdkman.io" | bash 安装 sdkman sdkman usage

  5. 如果下载速度太慢,可以前往 kotlin 下载二进制安装包,解压到任意位置,再将 解压后根目录中 bin 文件夹 添加到环境变量

    解压 .tar.gz 文件 用 tar -xzf 命令

  6. need install gradle (can not directly use kotlinc)

    using gradle to build project and run project

see this link Neovim for beginners

php

  • coc-phpls

web development in wsl2

lua

how to install lua and luarock 1. follow the offical doc

curl -R -O http://www.lua.org/ftp/lua-5.4.4.tar.gz
tar zxf lua-5.4.4.tar.gz
cd lua-5.4.4
make all test
2. configure the environment variable 3. run make local, and copy everything in install directories to /usr/local/bin/lua-5.4

python

meet with issue 600 fixed by deleting coc-python in directory

latex

installing texlive

sudo pacman -S texlive texlive-langchinese

或者 可参考 Linux 下的LaTex写作工具链 Makefiles

LATEX=xelatex #定义变量,指定编译引擎
LATEXOPT=--shell-escape #定义变量 指定编译参数
NONSTOP=--interaction=nonstopmode #定义变量 指定编译模式
LATEXMK=latexmk #采用latexmk来编译latex文档
LATEXMKOPT=-pdf #latexmk参数 输出pdf
CONTINUOUS=-pvc #若加入-pvc选项则可以持续检测文件改动并实时显示
MAIN=main #根文件名称

MAIN_SRC = $(patsubst %, %.tex, $(MAIN))

SOURCES= $(MAIN_SRC)  
FIGURES := $(shell find figures/* movies/* -type f)

all:    $(MAIN).pdf

$(MAIN).pdf: $(SOURCES) $(FIGURES)
    $(LATEXMK) $(LATEXMKOPT)  \
            -pdflatex="$(LATEX) $(LATEXOPT) $(NONSTOP) %O %S" $(MAIN)
force:
    rm $(MAIN).pdf
    $(LATEXMK) $(LATEXMKOPT) $(CONTINUOUS) \
            -pdflatex="$(LATEX) $(LATEXOPT) %O %S" $(MAIN)
clean:
    $(LATEXMK) -C $(MAIN)
    -rm -f $(MAIN).pdfsync
    -rm -rf *~ *.tmp
    -rm -f *.bbl *.blg *.aux *.end *.fls *.log *.out *.fdb_latexmk
once:
    $(LATEXMK) $(LATEXMKOPT) -pdflatex="$(LATEX) $(LATEXOPT) %O %S" $(MAIN)
debug:
    $(LATEX) $(LATEXOPT) $(MAIN)
.PHONY: clean force once all
  • download and build texlab
  • config settings
    "texlab.path": "$HOME/notes/tex/texlab/target/release/texlab",
    "texlab.build.onSave": true,
    "texlab.build.args": ["-xelatex", "-interaction=nonstopmode", "-synctex=1", "%f"],

git 代理

  • 根据这篇博客,配置了github的代理。git 代理
  • 如果遇到了从github拉取失败的情况,要么是没开clash 代理,要么是节点废了
  • 有时候通过 ssh 的方式 clone 仓库也会失败,这个时候需要配置 ssh 走 http 的代理
  • 设置 ssh 走 http 代理 doc

配置 Android Studio

配置 maven

  1. In IDEA find settings->build->Maven change User settings file, and Local Repository
  2. In the location of user settings file,touch a settings json, which Maven will read before execution
  3. In settings.json, add local repository and mirror . settings

    ~/.m_2/settings.xml is user config file ../conf/settings.xml is system config file The priority of user file weights than system configration file.

if you are not sure what script is being executed, you can somehow random change the contents see whether the change affect idea

  • for maven or some thing related to java, go to bilibli channel to see tutorial.
  • intelliJ offical doc is also a great reference

配置 gradle

  • To modify gradle location permanently, Add a environment variable GRADLE_USER_HOME, and set its value as your self defined location. for example D:\.gradle
  • To move location of avd. go ~/.android/avd, modify XXX.ini file
avd.ini.encoding=UTF-8
path=D:\avd\Pixel_XL_API_33_2.avd // change this to your desired location
path.rel=avd\Pixel_XL_API_33_2.avd
target=android-33

配置 vscode

vscode configration

  • which-key could specify function of same key-bindings for different circustances
  • multi-command
  • find the api for spercific action in vscode docs

reference dotfiles tasks

"terminal.integrated.fontFamily": "NotoSansMono Nerd Font"     
// amazing
"keyboard.dispatch": "keyCode"  
// keyboard
// Place your key bindings in this file to override the defaults
[
{
  "key": "ctrl+alt+t",  // you could use     "key": "ctrl+`",  if you wish
  "command": "workbench.action.closePanel",
  // "when": "terminalFocus"
},

{
  "key": "ctrl+alt+t",
  "command": "workbench.action.toggleMaximizedPanel",
  "when": "!terminalFocus"
},
{
  "key": "ctrl+shift+alt+z",
  "command": "workbench.action.tasks.runTask"
},
{ 
    "key": "tab",     
    "command": "selectNextSuggestion",
    "when": "editorTextFocus && suggestWidgetMultipleSuggestions && suggestWidgetVisible" },
{ 
    "key": "tab",                   
    "command": "-acceptSelectedSuggestion"
},
]

vscode cpp 调试

  1. 从 官网 拷贝 task.json, launch.json
  2. 选择 debug cpp/c 文件时,记得不要选 带有 /usr/bin/cpp 那个任务

cpp

  1. 之后就可以了

配置 ideavim

ideavimrc

  • how to use which key
  • how to find the task id
    • first, shift shift and search track action ID
    • perform and copy the action
    • write mappings map keyMappings <Action>({action_id})

不常用命令行

git

git stash pop 可以撤销git stash 操作并删除stash的记录

pandoc

!pandoc % -o %<.pdf --pdf-engine=xelatex -V CJKmainfont=KaiTi

\(a_1 + b_2 = c_3\)

ranger

  • need syntax highlighting
  • open pdf document for the first time is extremely slow

wget

wget --mirror --convert-links --adjust-extension --page-requisites --no-parent https://www.eecs189.org/sp18/

rclone

rclone mount oss:trace1729 /home/trace/rclone  --copy-links --no-gzip-encoding --no-check-certificate --allow-other --allow-non-empty --umask 000 --daemon

pacman

  1. pacman -Ss {{package}} s for search.
  2. pacman -Sc clear cache
  3. pacman -Scc clear all cache
  4. pacman -Rc {{package}} remove package
  5. pacman -Rs remove package and its dependency
  6. pacman -Rns remove package, its dependency and its global configration file
  7. pacman -Qe search user installed package
  8. pacman -R $(pacman -Qdtq)

当太久没更新

pacman-key --populate archlinux

pacman -S archlinux-keyring

更新出现报错

"Failed to commit transaction (conflicting files)" error

首先去 arch wiki 上找 pacman 的 trouble shooting.

使用 pacman -Qo 确定冲突的文件不是其他包的依赖后,可以将冲突文件重命名或者删除,再尝试更新

zellij

  1. 配置文件 ~/.config/zellij
  2. 布局文件 ~/.config/zellij/layouts
  3. 加载布局 zellij --layout {写文件名就好}

布局介绍 - tab 是一个满屏 - 一个 tab 下 可以有 多个 pane

参考配置

layout {
    pane split_direction="vertical" {
                    pane
                    pane
            }
}

gdb

  1. .gdbinit 可以预设一些gdb 命令 方便调试
  2. 需要在 ~/.config/gdb/gdbinit 里添加安全路径,.gdbinit 才能被执行
add-auto-load-safe-path /home/trace/trace/learning/open_course/6.s081/xv6-labs-2021/.gdbinit
add-auto-load-safe-path /home/trace/trace/learning/cpp/.gdbinit
  1. 如果 gdb 打印 异常
(gdb) p intervals[0][0]
$2 = (__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type &) @0x555555
572000: 15

可能是因为设置了 set auto-load safe-path XXX

Manjaro cheatsheet

  • How to installing fonts for manjaro
  • downloading ttf file
  • create directory for your font in /usr/share/fonts
  • move your ttf file into the directory you just created
  • Done!

  • 注意 使用 yay 时,需要开代理,而日终端默认是不走代理的,需要手动运行

export http_proxy=''
export https_proxt=''
  • i3wm 使用
  • font:pango {{fontsize}}
  • 需要在使用代理的终端下,开启浏览器,才能走代理
  • ./clash-linux-amd64-v3-v1.11.4 -f config.yml >/dev/null 2>& 1 &
  • source proxy.sh

  • 关闭代理

  • ps aux | grep clash
  • kill -9
  • source noproxy.sh

  • 键位绑定

  • xev show ascii code for keystroke
  • capslock: 66, esc: 9

  • 待折腾

  • 调整标签页的大小

  • When using fanyi command line tools

  • either using -S option to close voice
  • or you install relavent package pacman -S festival festival-englist

npm - 淘宝镜像https 证书过期了,而有些项目构建时,又指定 了淘宝镜像,导致构建失败。目前没找到解决办法 - 也许可以手动安装,但是不想折腾了。

卸载软件

  • 使用 pacman 卸载软件后,可能会有残留文件,一般检查一下几个文件位置
    • ~/.config/
    • ~/
    • /usr/share/
    • ~/cache/

bluetoothctl

首先启动服务

sudo systemctl enable bluetoothctl.service
sudo systemctl start bluetoothctl.service

再输入 bluetoothctl 进入命令行界面

bluetoothctl #连接交互命令
power on #开启控制器电源,默认关闭
devices #获取要配对设备的MAC
agent on #打开代理
pair MAC_ADDRESS #配对,输入MAC地址即可配对,建议使用Tab
connect MAC_ADDRESS #连接,建议使用Tab

如果输入 power on 后,出现 Failed to set power on: org.bluez.Error.Failed 错误, 返回终端输入 rfkill unblock bluetooth,再进入到 bluetoothctl 界面重新输入 power on

通知

如果qq不现实消息通知,可能是因为你开了 Do not Disturb 模式

服务器配置拾遗

How to deploy website using Apacha2

  1. install apache

    sudo apt update
    sudo apt install apache2
    

  2. config ufw (ubuntu firewall)

sudo ufw allow OpenSSH # for ssh into server 
sudo ufw allow 'Apache Full' # 为 apache 服务 放行
sudo ufw enable # 启用防火墙
3. 启动 apache 服务

sudo systemctl start apache2
  1. installing php, php plugin for apache, mysql, sql plugin for php

sudo apt install php libapache-mod-php mysql-server php-mysql

  1. the root dir is located at /var/www/html, You can modify the content in index.html

  2. mysql 服务

    After installing mysql service automaticaly activatied

First we need to config password for root Alter ...

Then run mysql_secure_installation

定时任务

0 22 * * * ncdu / -o ~/log/disk_$(date +\%Y\%m\%d_\%H\%M\%S).json

Side Notes

  • About systemctl
  • systemctl [start | reload | restart | stop] {{service}}

  • About ufw

  • ufw status
  • ufw allow in {{service}}
  • ufw app list

  • About Apache

  • apache2.conf 主配置
  • ports.conf 配置端口
  • conf-available
  • conf-enabled
  • mods-available 安装的插件
  • mods-enabled 启用的插件
  • sites-available 待使用的站点
  • sites-enabled 启用的站点

  • 查看端口占用情况

sudo netstat -tlnp | grep ':80'

文件描述符

&1 表示 序号为1 的 文件描述符,而非文件名为1文件

2>&1 表示 让文件描述符2指向 文件描述符1所指向的设备

cloud server + hexo

  1. 进入 trace1729.github.io, 输入 hexo new {post name} 新建博客
  2. hexo g 生产静态页面
  3. hexo d 将内容同步至 github
  4. oss 如果需要将文件上传至云端,可以使用这个

Github

Repo 导入 secrets.TOKEN

repo

涂鸦区

颜色主题调整

评论区~