====== Zsh ====== Intérprete de comandos (//shell//). * [[https://www.zsh.org/|Web oficial]] ===== Instalación ===== ==== Arch Linux ==== En Arch Linux, a través del paquete ''zsh''. ===== Configuración ===== La primera vez que se ejecute ''zsh'' se mostrará un "asistente": This is the Z Shell configuration function for new users, zsh-newuser-install. You are seeing this message because you have no zsh startup files (the files .zshenv, .zprofile, .zshrc, .zlogin in the directory ~). This function can help you with a few settings that should make your use of the shell easier. You can: (q) Quit and do nothing. The function will be run again next time. (0) Exit, creating the file ~/.zshrc containing just a comment. That will prevent this function being run again. (1) Continue to the main menu. (2) Populate your ~/.zshrc with the configuration recommended by the system administrator and exit (you will need to edit the file by hand, if so desired). --- Type one of the keys in parentheses --- * ''.zshevn'' * ''.zprofile'' * ''.zshrc'' * ''.zlogin'' ==== Cambiar shell de login por defecto ==== Para saber cuál es nuestra shell por defecto: echo $SHELL ==== zshrc ==== Contenido del fichero ''.zshrc'': # Habilitar el autocompletado: autoload -Uz compinit compinit ===== Atajos de teclado ===== * ''Ctrl'' + ''a'': mover el cursor ir al principio de la línea * ''Ctrl'' + ''e'': mover el cursor al final de la línea * ''Ctrl'' + ''p'': comando anterior (cursor arriba) * ''Ctrl'' + ''n'': siguiente comando (cursor abajo) * ''Alt'' + ''b'': retroceder una palabra * ''Alt'' + ''f'': avanzar una palabra * ''Ctrl'' + ''f'': avanzar un caracter * ''Ctrl'' + ''b'': retroceder un caracter * ''Ctrl'' + ''xx'': alternar entre el principio de la línea y la posición actual del cursor. * ''Ctrl'' + ''l'': limpiar la pantalla. * ''Alt'' + ''Del'': borrar la palabra anterior. * ''Alt'' + ''d'': borrar la palabra siguiente (a la posición del cursor). * ''Ctrl'' + ''d'': borrar la palabra sobre el cursor. * ''Ctrl'' + ''h'': borrar el caracter anterior al cursor. * ''Ctrl'' + ''w'': cortar la palabra anterior al cursor. * ''Ctrl'' + ''k'': cortar la línea después del cursor * ''Ctrl'' + ''u'': cortar/borrar la línea anterior al cursor * ''Alt'' + ''t'': intercambiar el orden con la palabra anterior * ''Ctrl'' + ''t'': intercambiar los últimos dos caracteres antes del cursor * ''Esc'' + ''t'': intercambiar las dos palabras antes del cursor * ''Ctrl'' + ''y'': pegar la última cosa cortada. * ''Alt'' + ''u'': convertir en mayúscula la siguiente palabra. * ''Alt'' + ''l'': convertir en minúscula la siguiente palabra. * ''Alt'' + ''c'': poner en mayúsculas la primera palabra y posicionarse al final de la misma. * ''Alt'' + ''r'': cancelar los cambios * ''ctrl'' + ''_'': deshacer. * ''Ctrl'' + ''r'': búsqueda en el historial * ''Ctrl'' + ''p'': comando anterior en el historial (retroceder en el historial de comando) * ''Ctrl'' + ''n'': siguiente comando en el historial (avanzar en el historial de comandos) * ''Ctrl'' + ''s'': volver al siguiente comando más reciente. * ''Ctrl'' + ''o'': ejecutar el comando encontrado con ''Ctrl'' + ''r'' o ''Ctrl'' + ''s'' * ''Ctrl'' + ''g'': salir del modo de búsqueda en el historial * ''!!'': repetir el último comando. * ''^abc­^­def'': ejecutar el último comando remplazando ''abc'' por ''def'' Todos los atajos de teclado pueden consultarse en el manual de ''readline'': ''man 3 readline'' ===== Órdenes incorporadas ===== A continuación se listan una serie de órdenes que vienen incluidas en zsh: * ''alias'' * ''bg'' * ''fg'' * ''jobs'' * ''break'' * ''cd'' * ''disown'' * ''echo'' * ''eval'' * ''exec'' * ''exit'' * ''export'' * ''history'' * ''kill'' * ''pwd'' * ''read'' * ''set'' * ''test'' * ''source'' * ''umask'' * ''unalias'' * ''unset'' * ''which'' * ''where'' Para ver el listado completo: ''man zshbuiltins'' ===== Modo Vi ===== ===== Oh My Zsh ===== [[https://ohmyz.sh/|Oh My Zsh]] es un conjunto de funciones, plugins y temas para Zsh. Esta instalación crea ficheros en ''/usr/share/oh-my-zsh'' por lo que habrá que reflejarlo en el fichero ''~/.zshrc'': ZSH_THEME="robbyrussell" plugins=( git ) source /usr/share/oh-my-zsh/oh-my-zsh.sh ===== Recursos ===== * [[https://github.com/romkatv/zsh4humans|Zsh for Humans: framework de configuración de zsh]] * [[https://github.com/zimfw/zimfw|Zim: framework de configuración de Zsh]] * [[https://github.com/ohmyzsh/ohmyzsh|Oh My Zsh: framework de configuración de zsh]] * [[https://apple.stackexchange.com/questions/361870/what-are-the-practical-differences-between-bash-and-zsh|What are the practical differences between Bash and Zsh?]] (StackExchange)