Arsenal de shell

Martin Tourneboeuf

November 17, 2020

Tabla de contenidos

1. Nota

         Sistema, Configuración, Nota

2. Shell

         Readline, Bash, Zsh

3. Edición

         Vim y Git

4. Viaje

         Tmux, Fsf, Rg

Entrenarse

Image not found

Afilar

Image not found

No precipitarse

Image not found

Notar

Image not found

Evernote

Image not found

Vimwiki

Image not found

1 presentation.md 2 script.md X
1 ---
2 title: Arsenal de shell
3 author: Tinmarino
4 description: Quien quiere la paz, prepara ... la paz!
Los patrones de código se aplican desde la más humilde
linea.
5 date: Novermber 14, 2020
6 make: pandoc -s --webtex -t slidy presentation.md -o
presentation.html
7 slidy-url: ../res/slidy
8 header-includes: |
9 <link rel="stylesheet" type="text/css" href="../res/
asciinema-player.css" />
10 <script src="../res/asciinema-player.js"></script>
11 <link rel="stylesheet" type="text/css" href="../res/
main-style.css" />
12 ---
13
14 ### Tabla de contenidos [22] ---------------------------
36 ### Entrenarse [12] ------------------------------------
48 ### Afilar [7] -----------------------------------------
55 ### No precipitarse [7] --------------------------------
62 ### Notar [7] ------------------------------------------
69 ### Evernote [7] ---------------------------------------
76 ### Vimwiki [24] ---------------------------------------
100 ### No repetir [7] -------------------------------------
107 ### Readline [9] ---------------------------------------
116 ### Bash [123] -----------------------------------------
239 ### Vim [168] ------------------------------------------
407 ### Vim Plugin [12] ------------------------------------
419 ### Vim Vimspector [10] --------------------------------
429 ### Git [8] --------------------------------------------
437 ### Ahorar tu cerebro [7] ------------------------------
444 ### Hacerlo de tu forma [11] ---------------------------
455 ### Simplificar [7] ------------------------------------
462 ### Tmux [10] ------------------------------------------
472 ### Fzf [9] --------------------------------------------
481 ### Rg<sup style="font-size:50%;"><a href="#foo [34] --
515 ### Mas [33] -------------------------------------------
548 ### Enlace [56] ----------------------------------------

No repetir

Image not found

Readline

Bash

Alias

alias mgr='su - almamgr'
alias op='su - almaop'

Variable

¡No dejes tu prompt[1] definirte, define tu prompt!

¿Qué debe contener un PS1[2]?

[1] Prompt: Indicador de commando

[2] PS1: Prompt String One

Image not found

Image not found

Image not found

Image not found

Image not found

command_not_found_handle

command_not_found_handle() {
  echo "Buuuu! I don't know command $1"
}
export -f command_not_found_handle

comando_malo
# OUTPUTS: Buuu ... comando_malo

Funciones: más que alias

function w () {
  if [[ -z "$1" ]]; then vim -c"call Windex(1)"
  else vim -c"call Windex(1)" -c":VimwikiGoto $1"
  fi
}
# Para ver las funciones definidas
typeset -f

Comandos: más que funciones

Definir sus propios commands en ~/.local/bin

Vim

Mi precioso

noremap s :update!<CR>

¿De que sirve el “s” (por defecto)?

¿Lo tienes mapeado?

¿Usas el “s” por defecto?

¿Porque no lo tienes mapeado?

A mano

let mapleader = ','
let maplocalleader = ','

¿Quién usa otro (delatenlo)?

Las cifras

" Foldlevel <- z
map z1  :set foldlevel=0<CR><Esc>
" ...
map z9  :set foldlevel=8<CR><Esc>

" Tab <- g (like gt and gT builtin: "Goto Tab")
noremap g1 :1tabnext<CR><Esc>
" ...
noremap g9 :9tabnext<CR><Esc>

¿Tienes ejemplos de uso de las teclas con cifras?

Plugin asincrónico

" Define: Lazy loader
function! TimerPack(timer) abort
  packadd ale
  packadd vimwiki
  " Youcompleteme: is verbose at init if no python
  try
    python3 '42'
    " Deletes the vim intro screen
    packadd youcompleteme
  catch | endtry
endfunction

" Call it
if has('timers')
  call timer_start(0, 'TimerPack')
else
  call TimerPack(42)
endif

¿Cómo manejas tus plugins?

Plugin justo a tiempo

noremap <leader>n :silent packadd devicons <CR>:silent packadd nerdtree <CR>:call NERDTreeToogle()<CR>
noremap <leader>u :silent packadd undotree <CR>:UndotreeToggle<CR>

¿Qué plugin cargas justo a tiempo?

Configuración genérica

filetype plugin indent on | syntax on
set encoding=utf-8 | scriptencoding uft-8
set mouse=a

if has('persistent_undo')
  set undodir=$HOME/.vim/undo
  set undofile
endif

¿Te gustaría que este instalado en almamgr?

Trucos

w ! sudo tee %
windo diffthis

¿Qué hace eso?

Vim Plugin

Vim Vimspector

Git

Ahorrar tu cerebro

Image not found

Hacerlo de tu forma

Image not found

Simplificar