Skip to content

Instantly share code, notes, and snippets.

@TheLurps
Last active April 12, 2021 09:52
Show Gist options
  • Select an option

  • Save TheLurps/bd9f0630b53376cd8351d53b6ceec174 to your computer and use it in GitHub Desktop.

Select an option

Save TheLurps/bd9f0630b53376cd8351d53b6ceec174 to your computer and use it in GitHub Desktop.
My setup script for Kali machines
#!/bin/bash
# Install various packages
sudo apt update && sudo apt upgrade -y
sudo apt install -y git tmux neovim nodejs npm python3-pip payloadsallthethings fzf
sudo npm install -g eslint-cli js-beautify
pip install --user pylint yapf isort
# Install and configure SpaceVim
curl -sLf https://spacevim.org/install.sh | bash
mkdir -vp ~/.SpaceVim.d/autoload
cat <<EOF >>~/.SpaceVim.d/init.toml
#=============================================================================
# dark_powered.toml --- dark powered configuration example for SpaceVim
# Copyright (c) 2016-2017 Wang Shidong & Contributors
# Author: Wang Shidong < wsdjeg at 163.com >
# URL: https://spacevim.org
# License: GPLv3
#=============================================================================
# All SpaceVim option below [option] section
[options]
# set spacevim theme. by default colorscheme layer is not loaded,
# if you want to use more colorscheme, please load the colorscheme
# layer
colorscheme = "gruvbox"
colorscheme_bg = "dark"
# Disable guicolors in basic mode, many terminal do not support 24bit
# true colors
enable_guicolors = true
# Disable statusline separator, if you want to use other value, please
# install nerd fonts
statusline_separator = "arrow"
statusline_inactive_separator = "arrow"
buffer_index_type = 4
enable_tabline_filetype_icon = true
enable_statusline_mode = false
automatic_update = 1
default_indent = 2
expand_tab = 1
vimcompatible = true
# Bootstrap Functions
bootstrap_before = "myspacevim#before"
bootstrap_after = "myspacevim#after"
[[layers]]
name = "autocomplete"
autocomplete_method = "deoplete"
auto-completion-return-key-behavior = "complete"
auto-completion-tab-key-behavior = "smart"
[[layers]]
name = "checkers"
[[layers]]
name = "denite"
[[layers]]
name = "format"
[[layers]]
name = "git"
[[layers]]
name = "lang#c"
[[layers]]
name = "lang#python"
python_file_head = [
'#!/usr/bin/env python',
'# -*- coding: utf-8 -*-',
'',
''
]
[[layers]]
name = "lang#javascript"
[[layers]]
name = 'shell'
default_position = 'top'
default_height = 30
[[layers]]
name = "sudo"
[[layers]]
name = "tmux"
[[layers]]
name = "github"
EOF
cat <<EOF >>~/.SpaceVim.d/autoload/myspacevim.vim
function! myspacevim#before() abort
" Python
let g:python3_host_prog = "/usr/bin/python3"
let g:loaded_python_provider = 0
endfunction
function! myspacevim#after() abort
set wrap
"au BufWinEnter * let w:m2=matchadd('ErrorMsg', '\%>80v.\+', -1)
set colorcolumn=80
" use system clipboard
set clipboard=unnamedplus
" unbind arrow keys for movement
nnoremap <Left> :echoe "Use h"<CR>
nnoremap <Right> :echoe "Use l"<CR>
nnoremap <Up> :echoe "Use k"<CR>
nnoremap <Down> :echoe "Use j"<CR>
endfunction
EOF
# Install and configure tmux
git clone https://github.com/tmux-plugins/tpm ~/.tmux/plugins/tpm
cat <<EOF >>~/.tmux.conf
# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'
set -g @plugin 'tmux-plugins/tmux-logging'
set -g @plugin 'tmux-plugins/tmux-sessionist'
set -g @plugin 'tmux-plugins/tmux-resurrect'
set -g @plugin 'tmux-plugins/tmux-continuum'
set -g @plugin 'tmux-plugins/tmux-online-status'
set -g @plugin 'tmux-plugins/tmux-battery'
set -g @plugin 'tmux-plugins/tmux-copycat'
set -g @plugin 'tmux-plugins/tmux-yank'
set -g @plugin 'tmux-plugins/tmux-cpu'
set -g @plugin 'tmux-plugins/tmux-open'
set -g @plugin 'tmux-plugins/tmux-pain-control'
set -g @plugin 'tmux-plugins/tmux-sensible'
# tmux-logging
set -g @logging-path "$HOME/log/tmux/%Y-%m-%d"
set -g @logging-filename "#{session_name}-#{window_name}-#{pane_index}.log"
set -g focus-events on
# tmux-continuum
set -g @continuum-restore 'off'
set -g @continuum-boot 'off'
# tmux-resurrect
set -g @resurrect-strategy-vim 'session'
set -g @resurrect-strategy-nvim 'session'
set -g @resurrect-capture-pane-contents 'on'
set-option -g set-titles on
# set shell
set-option -g default-shell $SHELL
# Remap prefix to screen
set -g prefix C-a
bind C-a send-prefix
unbind C-b
# Quality of life stuff
set -g history-limit 50000
set -g allow-rename off
# Join Windows
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key s command-prompt -p "send pane to:" "join-pane -t '%%'"
# Copy into clipboard
bind -T copy-mode-vi Enter send-keys -X copy-pipe-and-cancel "xclip -i -f -selection primary | xclip -i -selection clipboard"
# for tmux-cssh
bind-key = set-window-option synchronize-panes
# Search Mode VI (default is emac)
set-window-option -g mode-keys vi
set -g @shell_mode 'vi'
## COLORSCHEME: gruvbox dark (medium)
set-option -g status "on"
# default statusbar color
set-option -g status-style bg=colour237,fg=colour223 # bg=bg1, fg=fg1
# default window title colors
set-window-option -g window-status-style bg=colour214,fg=colour237 # bg=yellow, fg=bg1
# default window with an activity alert
set-window-option -g window-status-activity-style bg=colour237,fg=colour248 # bg=bg1, fg=fg3
# active window title colors
set-window-option -g window-status-current-style bg=red,fg=colour237 # fg=bg1
# pane border
set-option -g pane-active-border-style fg=colour250 #fg2
set-option -g pane-border-style fg=colour237 #bg1
# message infos
set-option -g message-style bg=colour239,fg=colour223 # bg=bg2, fg=fg1
# writing commands inactive
set-option -g message-command-style bg=colour239,fg=colour223 # bg=fg3, fg=bg1
# pane number display
set-option -g display-panes-active-colour colour250 #fg2
set-option -g display-panes-colour colour237 #bg1
# clock
set-window-option -g clock-mode-colour colour109 #blue
# bell
set-window-option -g window-status-bell-style bg=colour167,fg=colour235 # bg=red, fg=bg
## Theme settings mixed with colors (unfortunately, but there is no cleaner way)
set-option -g status-justify "left"
#set-option -g status-left-style attr="none"
set-option -g status-left-length "80"
set-option -g status-right-style none
set-option -g status-right-length "80"
set-window-option -g window-status-separator ""
set-option -g status-left "#[bg=colour241,fg=colour248] #S #[bg=colour237,fg=colour241,nobold,noitalics,nounderscore]"
set-option -g status-right "#[bg=colour237,fg=colour239 nobold, nounderscore, noitalics]#[bg=colour239,fg=colour246] %Y-%m-%d  %H:%M #[bg=colour239,fg=colour248,nobold,noitalics,nounderscore]#[bg=colour248,fg=colour237] #h "
set-window-option -g window-status-current-format "#[bg=colour214,fg=colour237,nobold,noitalics,nounderscore]#[bg=colour214,fg=colour239] #I #[bg=colour214,fg=colour239,bold] #W #[bg=colour237,fg=colour214,nobold,noitalics,nounderscore]"
set-window-option -g window-status-format "#[bg=colour239,fg=colour237,noitalics]#[bg=colour239,fg=colour223] #I #[bg=colour239,fg=colour223] #W #[bg=colour237,fg=colour239,noitalics]"
# vim: set ft=tmux tw=0 nowrap:
# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run '~/.tmux/plugins/tpm/tpm'
EOF
# Set neovim as default editor
sudo update-alternatives --set editor "/usr/bin/nvim"
sudo update-alternatives --set vi "/usr/bin/nvim"
sudo update-alternatives --set vim "/usr/bin/nvim"
# Rebind some keys
cat <<EOF >>~/.Xmodmap
!keycode 9 = Escape NoSymbol Escape NoSymbol Escape
keycode 9 = Escape asciitilde Escape NoSymbol Escape
!keycode 110 = Home NoSymbol Home NoSymbol Home
keycode 110 = Print NoSymbol Print NoSymbol Print
EOF
cat <<EOF >>~/.zshrc
if [ -f ~/.Xmodmap ]&& [ -n "${DISPLAY+x}" ]; then
xmodmap ~/.Xmodmap
fi
EOF
# Set aliases
cat <<EOF >>~/.zshrc
alias getme='echo "$(id -un)@$(hostname)_$(date -u +"%Y%m%d")"'
alias PayloadAllTheThings='glow "$(find /usr/share/payloadsallthethings -name "README.md" | fzf)" --pager'
EOF
# Configure git
cat <<EOF >~/.gitconfig
[push]
default = matching
followTags = true
[diff]
submodule = log
tool = vimdiff
[alias]
lg = !"git lg1"
lg1 = !"git lg1-specific --all"
lg2 = !"git lg2-specific --all"
lg3 = !"git lg3-specific --all"
lg1-specific = 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(auto)%d%C(reset)'
lg2-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(auto)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)'
lg3-specific = log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset) %C(bold cyan)(committed: %cD)%C(reset) %C(auto)%d%C(reset)%n'' %C(white)%s%C(reset)%n'' %C(dim white)- %an <%ae> %C(reset) %C(dim white)(committer: %cn <%ce>)%C(reset)'
ctags = !.git/hooks/ctags
ci = commit
br = branch
co = checkout
rb = rebase
sb = show-branch
st = status
staged = diff --staged
unstage = reset HEAD --
whoops = commit --amend
redo = commit --amend --reuse-message=HEAD
last = log -1 HEAD
[remote "origin"]
prune = true
[gpg]
program = /usr/bin/gpg2
[format]
signoff = true
[credential]
helper = store
[filter "lfs"]
process = git-lfs filter-process
required = true
clean = git-lfs clean -- %f
smudge = git-lfs smudge -- %f
[init]
templatedir = ~/.git_template
defaultBranch = main
[http]
sslVerify = true
[merge]
ff = no
commit = no
[pull]
ff = yes
EOF
# Install NerdFonts
mkdir -vp ~/.local/share/fonts/NerdFonts
curl https://github.com/ryanoasis/nerd-fonts/releases/download/v2.1.0/SourceCodePro.zip -L -o /tmp/SourceCodePro.zip && unzip -d ~/.local/share/fonts/NerdFonts /tmp/SourceCodePro.zip
chmod 644 ~/.local/share/fonts/NerdFonts/*.ttf
fc-cache -fv
# Gather some resources
git clone https://github.com/TheLurps/hacktricks ~/HackTricks
# Install Joplin
wget -O - https://raw.githubusercontent.com/laurent22/joplin/dev/Joplin_install_and_update.sh | bash
mkdir -vp ~/.joplin-data
# Install Glow
wget $(curl -s https://api.github.com/repos/charmbracelet/glow/releases/latest | grep browser_download_url | cut -d\" -f4 | grep linux_amd64.deb) -O /tmp/glow_linux_amd64.deb && sudo dpkg -i /tmp/glow_linux_amd64.deb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment