Skip to content

Instantly share code, notes, and snippets.

@afpro
Last active August 30, 2024 10:12
Show Gist options
  • Save afpro/2c8677281466347d56070d46f6d8b49c to your computer and use it in GitHub Desktop.
Save afpro/2c8677281466347d56070d46f6d8b49c to your computer and use it in GitHub Desktop.
osx config
[http]
proxy = "http://127.0.0.1:7890"
[net]
git-fetch-with-cli = true
[profile.release]
strip = true
lto = true
---
IndentWidth: 4
TabWidth: 4
UseTab: Never
Standard: Cpp11
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackParameters: false
BreakBeforeBraces: Custom
BraceWrapping:
AfterClass: false
AfterControlStatement: false
AfterEnum: false
AfterFunction: false
AfterNamespace: false
AfterStruct: false
AfterUnion: false
AfterExternBlock: false
BeforeCatch: false
BeforeElse: false
SplitEmptyFunction: false
SplitEmptyRecord: false
SplitEmptyNamespace: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: true
BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: true
ColumnLimit: 100
CompactNamespaces: true
ConstructorInitializerAllOnOneLineOrOnePerLine: false
Cpp11BracedListStyle: true
FixNamespaceComments: true
ForEachMacros: ['BOOST_FOREACH']
IncludeBlocks: Regroup
IndentCaseLabels: true
IndentPPDirectives: AfterHash
MaxEmptyLinesToKeep: 2
NamespaceIndentation: All
PointerAlignment: Right
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
#SpaceBeforeCtorInitializerColon: true
#SpaceBeforeInheritanceColon: true
SpaceBeforeParens: ControlStatements
#SpaceBeforeRangeBasedForLoopColon: true
SpaceInEmptyParentheses: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
BinPackArguments: false
BinPackParameters: false
ExperimentalAutoDetectBinPacking: false
AllowAllParametersOfDeclarationOnNextLine: false
[core]
quotepath = false
[init]
defaultBranch = main
[filter "lfs"]
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
process = git-lfs filter-process
required = true
[url "[email protected]:"]
insteadOf = https://github.com/
Host *
ServerAliveInterval 15
Host github.com
ProxyCommand nc -v -x 127.0.0.1:7890 %h %p
local wezterm = require 'wezterm'
local config = wezterm.config_builder()
function get_appearance()
if wezterm.gui then
return wezterm.gui.get_appearance()
end
return 'Dark'
end
function scheme_for_appearance(appearance)
if appearance:find 'Dark' then
return 'Darcula+'
else
return 'Github'
end
end
config.color_scheme = scheme_for_appearance(get_appearance())
config.window_background_opacity = 0.7
config.macos_window_background_blur = 20
config.font = wezterm.font('JetBrains Mono', { weight = 'DemiBold' })
config.font_size = 18
config.harfbuzz_features = { 'calt=0', 'clig=0', 'liga=0' }
config.initial_rows = 40
config.initial_cols = 120
config.keys = {
{
key = 'd',
mods = 'CMD',
action = wezterm.action.SplitVertical { domain = 'CurrentPaneDomain' },
},
{
key = 'd',
mods = 'CMD|SHIFT',
action = wezterm.action.SplitHorizontal { domain = 'CurrentPaneDomain' },
},
{
key = 'k',
mods = 'CMD',
action = wezterm.action.ClearScrollback 'ScrollbackAndViewport'
},
};
config.mouse_bindings = {
-- Change the default click behavior so that it only selects
-- text and doesn't open hyperlinks
{
event = { Up = { streak = 1, button = 'Left' } },
mods = 'NONE',
action = act.CompleteSelection 'ClipboardAndPrimarySelection',
},
-- and make CTRL-Click open hyperlinks
{
event = { Up = { streak = 1, button = 'Left' } },
mods = 'CTRL',
action = act.OpenLinkAtMouseCursor,
},
};
return config
# zsh plugin
plugins=(macos vi-mode)
# auto complete
autoload -U compinit && compinit
zstyle ':completion:*' menu select
# homebrew
export HOMEBREW_NO_AUTO_UPDATE=1
export HOMEBREW_NO_ANALYTICS=1
export HOMEBREW_NO_INSTALL_CLEANUP=1
eval "$(/opt/homebrew/bin/brew shellenv)"
# suggestion
fpath=(/opt/homebrew/opt/zsh-completions/share/zsh-completions $fpath)
source /opt/homebrew/opt/zsh-autosuggestions/share/zsh-autosuggestions/zsh-autosuggestions.zsh
# starship!
eval "$(starship init zsh)"
# utils
export LC_ALL=en_US.UTF-8
set -o vi
# up/down search key binding
bindkey "^[[A" history-beginning-search-backward
bindkey "^[[B" history-beginning-search-forward
# nvm
use-nvm() {
source /opt/homebrew/opt/nvm/nvm.sh
source /opt/homebrew/opt/nvm/etc/bash_completion.d/nvm
}
alias cnpm="npm --registry=https://registry.npmmirror.com \
--cache=$HOME/.npm/.cache/cnpm \
--disturl=https://npmmirror.com/mirrors/node \
--userconfig=$HOME/.cnpmrc"
# rust
# dependencies: 'cargo install cargo-zigbuild' and 'brew install zig' and 'cargo install cargo-xwin'
# rust
alias dyn-cargo-run='RUSTFLAGS="-C prefer-dynamic" CARGO_TARGET_DIR="./target/dynamic" cargo run'
alias cargo-windows='cargo xwin build --target x86_64-pc-windows-msvc'
alias cargo-pi='cargo zigbuild --target aarch64-unknown-linux-musl'
alias cargo-linux='RUSTFLAGS="-C target-feature=-crt-static" cargo zigbuild --target x86_64-unknown-linux-musl'
# proxy
export proxy_port=7890
use-http-proxy() {
export http_proxy=socks5h://127.0.0.1:$proxy_port
export https_proxy=socks5h://127.0.0.1:$proxy_port
export HTTP_PROXY=socks5h://127.0.0.1:$proxy_port
export HTTPS_PROXY=socks5h://127.0.0.1:$proxy_port
export DEFAULT_JVM_OPTS="-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890"
}
no-http-proxy() {
unset http_proxy
unset https_proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset DEFAULT_JVM_OPTS
}
with-proxy() {
http_proxy="http://127.0.0.1:$proxy_port" \
https_proxy="http://127.0.0.1:$proxy_port" \
HTTP_PROXY="http://127.0.0.1:$proxy_port" \
HTTPS_PROXY="http://127.0.0.1:$proxy_port" \
DEFAULT_JVM_OPTS="-Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=7890" \
GIT_SSH_COMMAND='ssh -o ProxyCommand="nc -v -x 127.0.0.1:$proxy_port %h %p"' \
$@
}
proxy-ssh() {
ssh -o ProxyCommand="nc -v -x 127.0.0.1:$proxy_port %h %p" $@
}
proxy-scp() {
scp -o ProxyCommand="nc -v -x 127.0.0.1:proxy_port %h %p" $@
}
use-git-proxy() {
export GIT_SSH_COMMAND='ssh -o ProxyCommand="nc -v -x 127.0.0.1:$proxy_port %h %p"'
}
no-git-proxy() {
unset GIT_SSH_COMMAND
}
# docker
alias dp64='docker pull --platform linux/amd64'
export CROSS_CONTAINER_OPTS='--platform linux/amd64'
# utility
alias gp='git pull --rebase --recurse-submodules'
alias tuna-pip-install='pip install -i https://pypi.tuna.tsinghua.edu.cn/simple'
alias tuna-pip-setup='pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple'
alias utm-clear='rm ~/Library/Containers/com.utmapp.UTM/.com.apple.containermanagerd.metadata.plist'
alias use-jemalloc='export DYLD_INSERT_LIBRARIES=/opt/homebrew/opt/jemalloc/lib/libjemalloc.dylib'
# init
use-http-proxy
use-git-proxy
config_path=$(ls $HOME/Library/Preferences/ByHost/com.apple.loginwindow.*.plist) # config file for loginwindow
chmod 000 $config_path # prevent osx from touch this file, can't delete, osx will recreate it.
edition="2021"
group_imports="StdExternalCrate"
imports_granularity="Crate"
reorder_imports=true
reorder_modules=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment