Skip to content

Instantly share code, notes, and snippets.

@franferrax
Last active May 24, 2023 15:45
Show Gist options
  • Save franferrax/806bc27e827ee2fda758b1d279e84c35 to your computer and use it in GitHub Desktop.
Save franferrax/806bc27e827ee2fda758b1d279e84c35 to your computer and use it in GitHub Desktop.
Configure Tools: vim, gdb

Usage

GDB

g="https://gist.githubusercontent.com/franferrax/806bc27e827ee2fda758b1d279e84c35"
bash <(curl -s "$g/raw/setup_gdb.sh?$(date +%s)") && unset g

VIM

g="https://gist.githubusercontent.com/franferrax/806bc27e827ee2fda758b1d279e84c35"
command="bash <(curl -s \"$g/raw/setup_vim.sh?\$(date +%s)\")"
bash -c "$command" && sudo bash -c "$command" && unset g command
#!/usr/bin/env bash
# Install GDB dashboard
rm -rf ~/.gdbinit
wget -P ~ https://raw.githubusercontent.com/cyrus-and/gdb-dashboard/master/.gdbinit
# Configure gdb
sed -ie '/Dashboard.start()$/r /dev/stdin' ~/.gdbinit <<'EOF'
# My Settings
set disassembly-flavor intel
dashboard -layout breakpoints source variables
dashboard source -style height 20
EOF
# Configure key bindings
cat > ~/.inputrc <<'EOF'
# https://serverfault.com/a/462893
$include /etc/inputrc
# GDB
$if gdb
"\e[18~":"step\n" # [F7] step into
"\e[18;5~":"stepi\n" # [Ctrl] + [F7] assembly step into
"\e[19~":"next\n" # [F8] step over
"\e[19;5~":"nexti\n" # [Ctrl] + [F8] assembly step over
"\e[20~":"continue\n" # [F9] continue/resume
"\e[19;2~":"finish\n" # [Shift] + [F8] step out
"\e[1;5A":"dashboard source scroll -1\n" # [Ctrl] + [up] scroll source up
"\e[1;5B":"dashboard source scroll +1\n" # [Ctrl] + [down] scroll source down
"\e[1;5H":"dashboard source scroll\n" # [Ctrl] + [home] scroll source to current line (reset)
$endif
EOF
# Try to install pygments
sudo dnf install -y python3-pygments
#!/usr/bin/env bash
[ "$USER" == "root" ] && HOME=/root
function _command_exists {
which "$1" >/dev/null 2>&1
}
function _install {
_command_exists "$1" || (
# Debian, Ubuntu, etc
_command_exists apt && sudo apt update && sudo apt install -y "$1"
# Fedora, RHEL, etc
_command_exists dnf && sudo dnf install -y "$1"
)
}
function _install_plug {
git clone --depth 1 "https://github.com/$1/$2" "$plugins/$2"
vim -u NONE -c "helptags $plugins/$2/doc" -c q
}
# Install requirements
_install vim
_install git
_install fzf
_install bat
# Determine if we need to use the Pathogen package manager
vim --version | grep --quiet --fixed-strings +packages || use_pathogen='yes'
# Cleanup previous settings
rm -rf ~/.vim*
# Install Pathogen (if required)
if [ "$use_pathogen" ]; then
mkdir -p ~/.vim/autoload
wget -P ~/.vim/autoload https://raw.githubusercontent.com/tpope/vim-pathogen/master/autoload/pathogen.vim
plugins=~/.vim/bundle
else
plugins=~/.vim/pack/plugins/start
fi
# Install VIM plugins
mkdir -p "$plugins"
_install_plug tpope vim-sensible
_install_plug tpope vim-sleuth
_install_plug tpope vim-vinegar
_install_plug itchyny lightline.vim
_install_plug mengelbrecht lightline-bufferline
_install_plug Yggdroot indentLine
_install_plug zigford vim-powershell
_install_plug bfrg vim-cpp-modern
_install_plug vim-python python-syntax
_install_plug ErichDonGubler vim-sublime-monokai
_command_exists fzf && (
_install_plug junegunn fzf
_install_plug junegunn fzf.vim
)
# Configure vim
if [ "$use_pathogen" ]; then
echo -e '" Load plugins\nexecute pathogen#infect()\n' >~/.vimrc
fi
cat >>~/.vimrc <<'EOF'
" Personal preferences
set number
set cursorline
set showcmd
try
" Use 24-bit truecolor (https://github.com/termstandard/colors)
set termguicolors
catch
set t_Co=256
endtry
" Color scheme
let g:sublimemonokai_term_italic = 1
colorscheme sublimemonokai
" Spell check settings
set spell
set spelllang=en
try
let &t_Cs = "\e[4:3m"
let &t_Ce = "\e[4:0m"
hi SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=red
hi SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl ctermul=yellow
catch
hi SpellBad guisp=red gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl
hi SpellCap guisp=yellow gui=undercurl guifg=NONE guibg=NONE ctermfg=NONE ctermbg=NONE term=underline cterm=undercurl
endtry
" Plugin settings
let java_comment_strings=1
let java_highlight_functions=1
let java_highlight_java_lang_ids=1
let g:cpp_attributes_highlight = 1
let g:cpp_member_highlight = 1
let g:cpp_simple_highlight = 1
let g:python_highlight_all = 1
let g:indentLine_char = '▏'
set showtabline=2
let g:lightline#bufferline#show_number = 1
let g:lightline#bufferline#shorten_path = 0
let g:lightline#bufferline#unnamed = '[No Name]'
let g:lightline = {
\ 'active': {
\ 'left': [ [ 'mode', 'paste' ], [ 'readonly', 'filename', 'modified' ] ]
\ },
\ 'tabline': {
\ 'left': [ ['buffers'] ],
\ 'right': [ ['close'] ]
\ },
\ 'component_expand': {
\ 'buffers': 'lightline#bufferline#buffers'
\ },
\ 'component_type': {
\ 'buffers': 'tabsel'
\ }
\ }
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment