Useful Commands

From bibbleWiki
Jump to navigation Jump to search

View Certificate Details

curl --insecure -vvI https://www.google.com 2>&1 | awk 'BEGIN { cert=0 } /^\* SSL connection/ { cert=1 } /^\*/ { if (cert) print }'

List or Delete Files With Spaces

find DONTUSESLASH -type d -name '.vs' -print0 | xargs -0 ls -l
find DONTUSESLASH -type d -name '.vs' -print0 | xargs -0 rm -rf

Size of Directories

du -sh -- *  | sort -rh

List Size of node_modules

find . -name "node_modules" -type d -prune | xargs du -chs

Delete node_modules

find . -name "node_modules" -type d -prune -exec rm -rf '{}' +

Testing for TLS v1.0 Support

nmap --script ssl-enum-ciphers -p 443 bibble.co.nz

Show Neovim Bindings

Here we go

:redir! > vim_keys.txt
:silent verbose map
:redir END

Leaders and Neovim

Leaders are keys you can press to activate a binding. In neovim you can set a leader key and then this is the key to activate a binding. E.g.

# Set leader to space
 vim.g.mapleader = " "
# Now space + e will open the diagnostic window. Copilot helped my out doing my LSP
 vim.keymap.set('n', '<leader>e', vim.diagnostic.open_float, { noremap = true, silent = true })

Running an LSP in Neovim

Been working on a language server protocol and this was provided do run my Typescript version

vim.lsp.start {
    name = "Typescript LSP",
    cmd = {
       "npx"/, "ts-node",
       vim.fn.expand("~/dev/projects/blah/server.ts")
    },
    capabilities = vim.lsp.protocoal.make_client_capabilities()
}

To List the Lsp to see if running you can type :LspInfo. This didn't work because I had to install the plugin to do this. Thank to copilot this was easy. Here to demonstrate for other plugins.

Install Vim-Plug

The easy bit was this which simply puts something in the right place

curl -fLo ~/.local/share/nvim/site/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim

Next I needed a Plugin manager which copilot suggested vim-plug

Add Plugin Config to init.vim

Presumably you add a line for each plugin

call plug#begin('~/.local/share/nvim/plugged')
Plug 'neovim/nvim-lspconfig'
call plug#end()

Update Plugins

In nvim we do :PlugInstall and hey presto :LspInfo