Last active
September 5, 2023 12:32
-
-
Save Yoshyn/d5e40efd0ccedf5140df074a7deec84e to your computer and use it in GitHub Desktop.
Setup mac
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Main step to the setup of my mac. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[color] | |
diff = auto | |
status = auto | |
branch = auto | |
[alias] | |
lg = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all | |
history = log --color --graph --pretty='format:%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative | |
st = status | |
inspect-branch= branch --all --sort=committerdate --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' | |
[push] | |
default = tracking | |
[apply] | |
whitespace = fix | |
[pull] | |
rebase = true | |
autostash = true | |
[rebase] | |
autostash = true | |
[merge] | |
autostash = true | |
[credential] | |
helper = cache --timeout=3600 | |
[core] | |
excludesfiles = ~/.gitignore_global | |
editor = vim | |
hooksPath = .githooks | |
[commit] | |
gpgsign = true | |
[rerere] | |
enabled = true | |
[diff] | |
submodule = log | |
[pager] | |
diff = diff-so-fancy | less --tabs=1,5 -RFX | |
show = diff-so-fancy | less --tabs=1,5 -RFX | |
[status] | |
submoduleSummary = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##################### | |
### BINDING ### | |
##################### | |
set-option -g default-command "reattach-to-user-namespace -l fish" | |
set -g history-limit 20000 | |
set -g base-index 1 | |
set -g pane-base-index 1 | |
bind r source-file ~/.tmux.conf \; display "Reloaded" | |
bind | split-window -h -c "#{pane_current_path}" | |
bind % split-window -h -c "#{pane_current_path}" | |
bind - split-window -v -c "#{pane_current_path}" | |
# act like vim and move with h, j, k, l | |
bind h select-pane -L | |
bind j select-pane -D | |
bind k select-pane -U | |
bind l select-pane -R | |
set -g mouse on | |
# ** Wheel scroll in pane | |
unbind -T root WheelUpPane | |
unbind -T root WheelDownPane | |
# Do mouse wheel-up to enter copy mode and do page-up | |
# https://groups.google.com/d/msg/tmux-users/XTrSVUR15Zk/3iyJLMyQ7PwJ | |
# Below works and allows the WheelUpPane binding in emacs-copy table to be effective | |
bind -T root WheelUpPane if -Ft= '#{mouse_any_flag}' 'send-keys -M' 'if -Ft= "#{pane_in_mode}" "send-keys -M" "copy-mode -u"' | |
# Pane resizing | |
bind -r H resize-pane -L 5 | |
bind -r J resize-pane -D 5 | |
bind -r K resize-pane -U 5 | |
bind -r L resize-pane -R 5 | |
###################### | |
### DESIGN CHANGES ### | |
###################### | |
## Status bar design | |
# status line | |
set -g status-justify centre | |
set -g status-style bg=default,fg=colour12 | |
set -g status-interval 2 | |
# messaging | |
set -g message-style fg=black,bg=yellow | |
set -g message-command-style fg=blue,bg=black | |
# window status | |
setw -g window-status-current-style fg=colour81,bg=colour238,bold | |
setw -g window-status-style fg=colour138,bg=colour235,none | |
setw -g window-status-bell-style fg=colour255,bg=colour1,bold | |
setw -g window-status-current-format '#[fg=white,bold]** #{window_index} #[fg=green]#{?#{==:#(basename $SHELL),#{window_name}},#{b:pane_current_path},#{window_name}} #{?#{==:#(basename $SHELL),#{pane_current_command}},,#[fg=blue](#{b:pane_current_command})} #[fg=white]**|' | |
setw -g window-status-format '#[fg=white,bold]#{window_index} #[fg=green]#{?#{==:#(basename $SHELL),#{window_name}},#{b:pane_current_path},#{window_name}} #{?#{==:#(basename $SHELL),#{pane_current_command}},,#[fg=blue](#{b:pane_current_command})} #[fg=white]|' | |
setw -g allow-rename on | |
setw -g automatic-rename on | |
# Info on left (I don't have a session display for now) | |
set -g status-left '' | |
# loud or quiet? | |
set-option -g visual-activity off | |
set-option -g visual-bell off | |
set-option -g visual-silence off | |
set-window-option -g monitor-activity off | |
set-option -g bell-action none | |
set -g default-terminal "screen-256color" | |
# The modes { | |
setw -g clock-mode-colour colour135 | |
setw -g mode-style fg=colour196,bg=colour238,bold | |
# } | |
# The panes { | |
set -g pane-border-style fg=black | |
set -g pane-active-border-style fg=brightred | |
set -g pane-border-style bg=colour235,fg=colour238 | |
set -g pane-active-border-style bg=colour236,fg=colour51 | |
set -g pane-border-status top | |
set -g pane-border-format "[#[fg=white]#{?pane_active,#[bold],} :#{pane_index}: #{pane_title} #[fg=default,nobold]] #{pane_current_command} " | |
#set -g status-left '#(~/bin/display_tmux_pane_pwd.sh)' | |
# } | |
# The statusbar { | |
set -g status-position bottom | |
set -g status-style bg=colour234,fg=colour137,dim | |
set -g status-left "[#[fg=green]#{session_name},#[fg=yellow]#{window_index},#[fg=cyan]#{pane_index}#[default]]#[fg=chartreuse] > #[fg=red] #(whoami)#[default]#[fg=chartreuse] > #[fg=blue]ⓦ #(curl --max-time 2 -s https://checkip.amazonaws.com)#[default]" | |
set -g status-right "#[fg=red]🔋 #(pmset -g batt | awk 'NR==2 { gsub(/;/,\"\"); print $3 }')#[fg=chartreuse] < #[fg=gray]~#(uptime | grep -ohe 'up .*' | sed 's/,//g' | awk '{ print $2\" \"$3 }')#[fg=chartreuse] < #[fg=aqua]%d-%m-%Y#[fg=chartreuse] < #[fg=green]%H:%M" | |
set -g status-right-length 40 | |
set -g status-left-length 60 | |
# } | |
# The messages { | |
set -g message-style fg=colour232,bg=colour166,bold | |
# } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
" URL: http://vim.wikia.com/wiki/Example_vimrc | |
" Authors: http://vim.wikia.com/wiki/Vim_on_Freenode | |
" Description: A minimal, but feature rich, example .vimrc. If you are a | |
" newbie, basing your first .vimrc on this file is a good choice. | |
" If you're a more advanced user, building your own .vimrc based | |
" on this file is still a good idea. | |
"------------------------------------------------------------ | |
" Features {{{1 | |
" | |
" These options and commands enable some very useful features in Vim, that | |
" no user should have to live without. | |
" Set 'nocompatible' to ward off unexpected things that your distro might | |
" have made, as well as sanely reset options when re-sourcing .vimrc | |
set nocompatible | |
" Attempt to determine the type of a file based on its name and possibly its | |
" contents. Use this to allow intelligent auto-indenting for each filetype, | |
" and for plugins that are filetype specific. | |
filetype indent plugin on | |
" Enable syntax highlighting | |
syntax on | |
"------------------------------------------------------------ | |
" Must have options {{{1 | |
" | |
" These are highly recommended options. | |
" Vim with default settings does not allow easy switching between multiple files | |
" in the same editor window. Users can use multiple split windows or multiple | |
" tab pages to edit multiple files, but it is still best to enable an option to | |
" allow easier switching between files. | |
" | |
" One such option is the 'hidden' option, which allows you to re-use the same | |
" window and switch from an unsaved buffer without saving it first. Also allows | |
" you to keep an undo history for multiple files when re-using the same window | |
" in this way. Note that using persistent undo also lets you undo in multiple | |
" files even in the same window, but is less efficient and is actually designed | |
" for keeping undo history after closing Vim entirely. Vim will complain if you | |
" try to quit without saving, and swap files will keep you safe if your computer | |
" crashes. | |
set hidden | |
" Note that not everyone likes working this way (with the hidden option). | |
" Alternatives include using tabs or split windows instead of re-using the same | |
" window as mentioned above, and/or either of the following options: | |
" set confirm | |
" set autowriteall | |
" Better command-line completion | |
set wildmenu | |
" Show partial commands in the last line of the screen | |
set showcmd | |
" Highlight searches (use <C-L> to temporarily turn off highlighting; see the | |
" mapping of <C-L> below) | |
set hlsearch | |
" Modelines have historically been a source of security vulnerabilities. As | |
" such, it may be a good idea to disable them and use the securemodelines | |
" script, <http://www.vim.org/scripts/script.php?script_id=1876>. | |
" set nomodeline | |
"------------------------------------------------------------ | |
" Usability options {{{1 | |
" | |
" These are options that users frequently set in their .vimrc. Some of them | |
" change Vim's behaviour in ways which deviate from the true Vi way, but | |
" which are considered to add usability. Which, if any, of these options to | |
" use is very much a personal preference, but they are harmless. | |
" Use case insensitive search, except when using capital letters | |
set ignorecase | |
set smartcase | |
" Allow backspacing over autoindent, line breaks and start of insert action | |
set backspace=indent,eol,start | |
" When opening a new line and no filetype-specific indenting is enabled, keep | |
" the same indent as the line you're currently on. Useful for READMEs, etc. | |
set autoindent | |
" Stop certain movements from always going to the first character of a line. | |
" While this behaviour deviates from that of Vi, it does what most users | |
" coming from other editors would expect. | |
set nostartofline | |
" Display the cursor position on the last line of the screen or in the status | |
" line of a window | |
set ruler | |
" Always display the status line, even if only one window is displayed | |
set laststatus=2 | |
" Instead of failing a command because of unsaved changes, instead raise a | |
" dialogue asking if you wish to save changed files. | |
set confirm | |
" Use visual bell instead of beeping when doing something wrong | |
set visualbell | |
" And reset the terminal code for the visual bell. If visualbell is set, and | |
" this line is also included, vim will neither flash nor beep. If visualbell | |
" is unset, this does nothing. | |
set t_vb= | |
" Enable use of the mouse for all modes | |
set mouse=a | |
" Set the command window height to 2 lines, to avoid many cases of having to | |
" "press <Enter> to continue" | |
set cmdheight=2 | |
" Display line numbers on the left | |
set number | |
" Quickly time out on keycodes, but never time out on mappings | |
set notimeout ttimeout ttimeoutlen=200 | |
" Use <F11> to toggle between 'paste' and 'nopaste' | |
set pastetoggle=<F11> | |
"------------------------------------------------------------ | |
" Indentation options {{{1 | |
" | |
" Indentation settings according to personal preference. | |
" Indentation settings for using 4 spaces instead of tabs. | |
" Do not change 'tabstop' from its default value of 8 with this setup. | |
set shiftwidth=4 | |
set softtabstop=4 | |
set expandtab | |
" Indentation settings for using hard tabs for indent. Display tabs as | |
" four characters wide. | |
"set shiftwidth=4 | |
"set tabstop=4 | |
"------------------------------------------------------------ | |
" Mappings {{{1 | |
" | |
" Useful mappings | |
" Map Y to act like D and C, i.e. to yank until EOL, rather than act as yy, | |
" which is the default | |
map Y y$ | |
" Map <C-L> (redraw screen) to also turn off search highlighting until the | |
" next search | |
nnoremap <C-L> :nohl<CR><C-L> | |
"------------------------------------------------------------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# file : .config/fish/functions/dnsmasq_assign.fish | |
# Assign or replace or remove into dnsmasq a domain | |
# Example : | |
# * (assign or replace) dnsmasq_assign domain.name 127.0.0.1 | |
# * (remove) dnsmasq_assign domain.name | |
function dnsmasq_assign --description "dnsmasq_assign <domain.name> [<ip_address>]" | |
set domain_name $argv[1] | |
set ip_adress $argv[2] | |
sed -i '' -e :a -e '/^\n*$/{$d;N;};/\n$/ba' /usr/local/etc/dnsmasq.conf # remove new line at the end of the file | |
if test (count $argv) -eq 0 | |
echo "No argument given" | |
else if ! test -n "$ip_adress" | |
sed -i '' 's/address=\/'$domain_name'\/.*//' /usr/local/etc/dnsmasq.conf | |
sudo rm -f /etc/resolver/$domain_name | |
else | |
grep -q "address=/"$domain_name"/" /usr/local/etc/dnsmasq.conf && sed -i '' 's/address=\/'$domain_name'\/.*/address=\/'$domain_name'\/'$ip_adress'/' /usr/local/etc/dnsmasq.conf || echo "address=/$domain_name/$ip_adress" >> /usr/local/etc/dnsmasq.conf | |
dnsmasq_resolv $domain_name | |
end | |
echo "Last 5 lines of /usr/local/etc/dnsmasq.conf : " | |
tail -5 /usr/local/etc/dnsmasq.conf | |
end | |
# Set a domain to be resolv in local (so by dnsmasq in our case) | |
# Example : | |
# * dnsmasq_resolv myip.opendns.com | |
function dnsmasq_resolv --description "dnsmasq_resolv <domain.name>" | |
set domain_name $argv[1] | |
sudo mkdir -p /etc/resolver/ | |
bash -c "sudo tee /etc/resolver/$domain_name > /dev/null <<EOF | |
nameserver 127.0.0.1 | |
domain $domain_name | |
search_order 1 | |
EOF" | |
echo "List of domains into /etc/resolver ($domain_name resolver is 127.0.0.1) :" | |
ls /etc/resolver/ | |
end | |
## Check & usage | |
# sudo brew services start dnsmasq | |
# sudo brew services list | |
# dig +short perdu.com | |
# dig +short perdu.com @127.0.0.1 | |
# sudo brew services restart dnsmasq | |
# sudo brew services list | |
# dnsmasq_assign perdu.com 127.0.0.1 | |
# dig +short perdu.com | |
# dig +short perdu.com @127.0.0.1 | |
# dnsmasq_assign perdu.com | |
# sudo brew services stop dnsmasq | |
## wtf & kill ? | |
# sudo lsof -i -n -P | grep TCP | grep dnsmasq | |
# ps aux | grep dnsmasq | grep -v grep | awk '{print $2}' | sudo xargs kill -9 | |
# sudo launchctl unload -w /Library/LaunchDaemons/homebrew.mxcl.dnsmasq.plist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
https://realjenius.com/2020/05/30/oh-my-fish/ | |
https://remysharp.com/2018/08/23/cli-improved | |
xcode-select --install | |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" | |
brew install iterm2 curl wget fasd fish | |
echo /opt/homebrew/bin/fish | sudo tee -a /etc/shells | |
chsh -s /opt/homebrew/bin/fish | |
echo 'fish_add_path /opt/homebrew/bin' >> ~/.config/fish/config.fish | |
curl -L https://get.oh-my.fish | fish | |
omf install bobthefish | |
omf install foreign-env | |
omf install fasd | |
fish_update_completions | |
(https://github.com/oh-my-fish/theme-bobthefish) | |
brew tap homebrew/cask-fonts | |
brew install font-hack-nerd-font | |
set -g theme_nerd_fonts yes | |
echo "fenv source /etc/profile" >> ~/.config/fish/config.fish | |
echo "fenv source ~/.profile" >> ~/.config/fish/config.fish | |
Set the font into preference/profile/text | |
brew install bat prettyping fzf htop diff-so-fancy fd ncdu tldr jq lsd awk vim tldr curl git | |
brew install rs/tap/curlie rs/tap/dnstrace | |
echo "alias ls=lsd" > ~/.config/fish/functions/ls.fish | |
echo "alias curl=curlie" > ~/.config/fish/functions/curl.fish | |
echo "alias ping=prettyping" > ~/.config/fish/functions/ping.fish | |
echo "alias cat=bat" > ~/.config/fish/functions/cat.fish | |
echo "alias help=tldr" > ~/.config/fish/functions/help.fish | |
echo "alias preview=\"fzf --preview 'bat --color \"always\" {}'\"" > ~/.config/fish/functions/preview.fish | |
echo "alias du=\"ncdu --color dark -rr -x --exclude .git --exclude node_modules\"" > ~/.config/fish/functions/du.fish | |
bash -c "cat <<EOT >> ~/.config/fish/functions/what_is_my_ip.fish | |
function what_is_my_ip | |
echo 'Local : '(eval ifconfig | grep inet | grep -v inet6 | grep -v 127.0.0.1 | cut -d ' ' -f2) | |
echo 'Outside ( amazon.com ) : '(curl -s https://checkip.amazonaws.com) | |
echo 'Outside ( ipinfo.io) :'; curl -s http://ipinfo.io | jq | |
end | |
EOT" | |
brew install sublime-text tmux reattach-to-user-namespace tree vlc git gimp knock wireshark util-linux dnsmasq iproute2mac gnupg cmake ngrok nmap arp-scan | |
https://stackoverflow.com/questions/40523307/brew-install-docker-does-not-include-docker-engine/43365425#43365425 | |
brew install --cask docker | |
wget https://gist.githubusercontent.com/Yoshyn/d5e40efd0ccedf5140df074a7deec84e/raw/4fcc1e9cf5c011bfebc4ed36e1d34115a96ac96d/.tmux.conf | |
wget https://gist.githubusercontent.com/Yoshyn/d5e40efd0ccedf5140df074a7deec84e/raw/66085555532bf80b4e669a0d0438a90bf8f26b56/.vimrc | |
TODO : | |
Create ssh & gpg key (follow github flow) | |
my_personal_email="[email protected]" | |
ssh-keygen -t ed25519 -C $my_personal_email -f $HOME/.ssh/id_personal_ed25519 -N "" | |
bash -c "cat <<EOT >> ~/.ssh/config | |
IgnoreUnknown Password | |
Host * | |
ForwardAgent yes | |
Host github.com | |
User git | |
IdentityFile ~/.ssh/id_personal_ed25519 | |
EOT" | |
pbcopy < ~/.ssh/id_personal_ed25519.pub | |
Then add it to github and test | |
ssh -T [email protected] | |
GPG key : | |
gpg --quick-gen-key $my_personal_email | |
mkdir -p ~/workspaces/personal | |
mkdir ~/.git | |
check https://gist.github.com/bgauduch/06a8c4ec2fec8fef6354afe94358c89e for multiple gpg account | |
wget https://gist.githubusercontent.com/Yoshyn/d5e40efd0ccedf5140df074a7deec84e/raw/ba9651ae79ff3c76f06d0d5b6296436d4a981c6e/.gitconfig | |
git config --file=.git/config.personal --add user.name personal_username | |
signingKey=$(gpg --list-secret-keys --keyid-format LONG | grep -B 2 $my_personal_email | head -1 | awk -F '/| ' '{print $5}') | |
gpg --armor --export $signingKey | pbcopy | |
Then add it to github | |
git config --file=.git/config.personal --add user.signingkey $signingKey | |
git config --global --add includeif.gitdir:~/workspaces/personal/.path .git/config.personal | |
brew install slack microsoft-outlook android-file-transfer balenaetcher licecap onyx lulu paintbrush wireshark | |
brew install awscli session-manager-plugin | |
brew install kubecolor/tap/kubecolor | |
echo "alias kubectl=kubecolor" > ~/.config/fish/functions/kubectl.fish | |
brew upgrade --gredy |
How to add missing manpage (& fish completion) to some package :
If there's some missing completion but the tool provide an help page like manpage, instead of create your own completion you can use the following (Example with mitmproxy) :
brew install help2man
mkdir -p /opt/homebrew/Cellar/mitmproxy/10.0.0/share/man/man1/
help2man mitmproxy > /opt/homebrew/Cellar/mitmproxy/10.0.0/share/man/man1/mitmproxy.1
brew unlink mitmproxy && brew link mitmproxy
fish_update_completions
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
iterm send text at start :
tmux attach -t startup || tmux new -s startup
Also add hack nert font in iterm Preference > Profile > text