开发环境中的技巧
对于个人的开发环境,有时候一些小的技巧很难再被记住了,所以只好收录在某处
Install golang 1.12 on ubuntu 18
https://gophp.io/how-to-install-go-1-12-on-ubuntu-18/
1
2
3
4
5
6
7
sudo add-apt-repository ppa:longsleep/golang-backports -y
sudo apt-get install -y software-properties-common
sudo apt-get update
sudo apt-get install -y golang-1.12
echo 'PATH="$PATH:/usr/lib/go-1.12/bin"' >> ~/.profile
source ~/.profile
go version
ssh to windows x linux sub-system
https://www.illuminiastudios.com/dev-diaries/ssh-on-windows-subsystem-for-linux/
Install zsh and ohmyzsh - WSL
1
2
3
sudo apt install -y zsh zsh-doc
chsh -s /bin/bash
sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
https://github.com/ohmyzsh/ohmyzsh/wiki/Installing-ZSH
https://github.com/ohmyzsh/ohmyzsh/wiki/Plugins
在 Oh-My-ZSH wiki27 上可以看到完整的插件列表。
Z 高级命令的完整列表,可以访问这个 GitHub 仓库29,或者观看关于 Z 的命令行高手视频。
https://www.zcfy.cc/article/become-a-command-line-power-user-with-oh-my-zsh-and-z
Convert Newline to LF, From CRLF
1
2
brew install dos2unix
find . -type f -print0 | xargs -0 dos2unix
Disable word-wrap in a Terminal
macOS
lifted directly from https://apple.stackexchange.com/a/210666/115119
Props to @michid
Disable line wrapping:
1
tput rmam
Enable line wrapping:
1
tput smam
Linux
Found a good answer from superuser, that works out of the box for gnome-terminal
, and probably for other terminals as well:
1
setterm -linewrap off
You can disable line wrapping for less
, tail
and every other command under the Linux sun with:
1
tput rmam
To restore line wrapping use:
1
tput smam
Uninstalling Visual Studio for Mac
https://docs.microsoft.com/en-us/visualstudio/mac/uninstall?view=vsmac-2019
卸载 Visual Studio for Mac
macos delete old days in time machine
How to delete older Time Machine backups
Delete a file from your Time Machine backup disk - Apple …
[How to delete older Time Machine backups | iMorewww](https://www.imore.com/how-delete-older-time-machine-backups) |
How can I manually delete old backups to free space for Time Machine?
Be careful with sudo and making sure you pick the correct Mac’s files since there is no undo or confirmation of the following command:
1
sudo tmutil delete /Volumes/drive_name/Backups.backupdb/old_mac_name
The sudo command needs your password (and it won’t echo to the screen, so just type it and pause to be sure you’re dating the correct files before pressing enter). If you want to be safer, you can pick one snapshot to delete first to be sure the command works as intended. This is nice since it could take hours to clean up some larger backup sets and you want to leave the Mac confident it’s deleting the correct information store.
You can use the tmutil
tool to delete backups one by one.
1
sudo tmutil delete /Volumes/drive_name/Backups.backupdb/mac_name/YYYY-MM-DD-hhmmss
Since tmutil
was introduced with Lion, this will not work on earlier OS versions.
If you want to get the current directory of backups (there can be multiple destinations defined and only one will be “current”)
1
sudo tmutil machinedirectory
Fastest way to delete all Timemachine Backups for a machine
If you’ve got:
Operation Not Permitted
after executing
1
sudo rm -rf Backups.backupdb
you should follow this approach, which is adding bypass
before the remove command:
1
sudo /System/Library/Extensions/TMSafetyNet.kext/Contents/Helpers/bypass rm -rfv Backups.backupdb
How to delete old Time Machine backups on a Mac computer in 2 ways, to free up storage space
How to delete (tmutil delete) all old backups from TimeMachine - keep only current full backup
取得最新的 gitlab 备份文件名
对于 gitlab 服务器,当你启用了自动备份功能之后,相应的备份文件会被定时生成。
由于在备份文件夹中有多个 tar 文件,当需要拖回本地时可能往往只想最新的一个,因此需要筛选一下文件名。以下假设你能够自动免密登录到 GITLAB 服务器:
1
2
3
4
5
6
7
GITLAB_HOST=my-git.com
LOCAL_TARGET=$HOME/Downloads/
FN=$(ssh $GITLAB_HOST 'sudo ls -la --color /var/opt/gitlab/backups/*.tar|tail -1|awk "{print \$NF}"')
# 下载到本地
rsync -avrztopg --progress $GITLAB_HOST:$FN $LOCAL_TARGET
🔚
留下评论