sudo sed -i 's/archive.ubuntu.com/mirrors.ustc.edu.cn/g' /etc/apt/sources.list
sudo apt update
sudo apt dist-upgrade
sudo apt install zsh autojump
sudo apt install vim ctags
sudo apt install build-essential
sudo apt install proxychains
3.1 Zsh: oh-my-zsh
sh -c "$(wget https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh -O -)"
# Copy .zshrc to $HOME
修改/etc/proxychains.conf
末尾行:
socks4 127.0.0.1 9095
为
# V2ray
socks5 127.0.0.1 10808
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
# Copy .vimrc to $HOME
(1) Update vim to 8.2
sudo add-apt-repository ppa:jonathonf/vim
sudo apt update
sudo apt install vim
(2) Install Prerequisites
# C/C++ lsp
sudo snap install ccls
sudo apt install bear
# Fortran lsp
pip3 install fortran-language-server
# VIM coc-plugins
# :CocInstall coc-pyright
(3) C/C++ generate compile_commands.json
-
For projects using
cmake
likeFlameMaster
# Recompile with `-DCMAKE_EXPORT_COMPILE_COMMANDS=1 option` cmake ../Repository -DCMAKE_BUILD_TYPE=Release -DCMAKE_EXPORT_COMPILE_COMMANDS=1 cmake --build . --parallel --target install --config Release cp compile_commands.json ../Repository/
-
For projects using
make
likeOpenFOAM
See this tutorial.
Modify OpenFOAM-2.3.1/wmake/wmake:
+#------------------------------------------------------------------------------ +# check if bear is installed and we are not already running under bear +#------------------------------------------------------------------------------ + +if [ -z "${RUNNING_UNDER_BEAR}" ] ; then + if ! bear --version > /dev/null ; then + echo "WARNING: bear is not installed -> There will be no compile_commands.json output." 1>&2 + elif printf '%s\n%s\n' "bear 3.0.0" "$(bear --version)" | sort -V -C ; then + #bear version >= 3.0.0 + export RUNNING_UNDER_BEAR=true + mkdir -p $FOAM_LIBBIN + bear --append --output $FOAM_LIBBIN/../compile_commands.json -- wmake $@ + exit $? + elif printf '%s\n%s\n' "bear 2.0.0" "$(bear --version)" | sort -V -C ; then + #bear version >= 2.0.0 + export RUNNING_UNDER_BEAR=true + mkdir -p $FOAM_LIBBIN + bear --append -o $FOAM_LIBBIN/../compile_commands.json wmake $@ + exit $? + else + echo "WARNING: bear version is below 2.0.0 -> There will be no compile_commands.json output." 1>&2 + fi +fi
Add script
vscode-settings
to OpenFOAM-2.3.1/bin/tools.Generate VSCode setting files:
cd $WM_PROJECT_DIR mkdir .vscode ./bin/tools/vscode-setting > .vscode/settings.json # Clean OpenFOAM installation wclean all # Re-build ./Allwmake
Create softlink for
VIM
/coc.nvim
:cd $WM_PROJECT_DIR ln -s ~/OpenFOAM/OpenFOAM-2.3.1/platforms/linux64GccDPOpt/compile_commands.json ./compile_commands.json
(4) Appendix:
coc-settings.json
under~/.vim
:{ "languageserver": { "ccls": { "command": "ccls", "filetypes": ["c", "cc", "cpp", "c++", "objc", "objcpp"], "rootPatterns": [".ccls", "compile_commands.json", ".git/", ".root"], "initializationOptions": { "cache": { "directory": ".cache/ccls" }, "highlight": {"lsRanges": true } } }, "fortran": { "command": "fortls", "filetypes": ["fortran"], "rootPatterns": [".fortls", ".git/"] } }
Follow these steps or this tutorial
- Create an account at Zerotier
- Create A Network and copy the Network ID
- Install Zerotier clients on your computers. Here I've a Linux workstation running Ubuntu 18.04 and a laptop running Windows 10
- For Linux:
sudo zerotier-cli join YOUR_NETWORK_ID
- For Windows: Right click the zerotier tray icon and Join Network.
- For Linux:
- Autorize these two devices in the zerotier web-ui. You can see the virtual IP address of each device.
-
- Install packages
# Packages sudo apt install tigervnc-standalone-server tigervnc-xorg-extension tigervnc-viewer
-
- Set the vnc password
tigervncpasswd
-
- Set-up vnc desktop environment
Create~/.vnc/xstartup
and paste the following content to it. (I have gnome desktop installed.)
#!/bin/sh # Start Gnome 3 Desktop [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources vncconfig -iconic & dbus-launch --exit-with-session gnome-session &
- Set-up vnc desktop environment
-
- Start vnc-server and listening from anywhere
tigervncserver -localhost no
-
- Check the vnc server port
Output:tigervncserver -list
For example,TigerVNC server sessions: X DISPLAY # PROCESS ID :1 9332
:1
is the port which is used to connect to the server in the viewer's side.
- Download and install Real VNC
- Click
File
->New connection
and input the IP address of Ubuntu at Zerotier network. For example:192.168.29.110:1
.:1
stands for the port of the vnc server.