Diferencias
Muestra las diferencias entre dos versiones de la página.
Ambos lados, revisión anterior Revisión previa Próxima revisión | Revisión previa | ||
tutorial_de_fish [2022/06/28 22:31] – [Prompt] peron | tutorial_de_fish [2023/06/06 19:42] (actual) – [Funciones incorporadas] peron | ||
---|---|---|---|
Línea 5: | Línea 5: | ||
==== Activar el intérprete de comandos Fish ==== | ==== Activar el intérprete de comandos Fish ==== | ||
- | <code bash> | + | En nuestro sistema [[BSD]] podrás [[interpretes de comandos# |
- | + | <code bash>chsh -s / | |
- | En la línea '' | + | Deberás reiniciar |
- | + | ||
- | <code bash>/ | + | |
- | + | ||
- | Guarda los cambios y reinicia | + | |
==== Ejecutar Comandos ==== | ==== Ejecutar Comandos ==== | ||
- | [[Fish shell]] ejecuta comandos como cualquier otra [[interpretes de comandos|shell]]: | + | [[fish|Fish shell]] ejecuta comandos como cualquier otra [[interpretes de comandos|shell]]: |
<code bash> | <code bash> | ||
Línea 226: | Línea 222: | ||
env | grep MiVariable | env | grep MiVariable | ||
- | MyVariable=AlgunValue</ | + | MiVariable=AlgunValor</ |
- | También puedes des-exportarlas con **--unexport** | + | También puedes des-exportarlas con **--unexport** |
¡Esto también opera a la inveersa! Si fish comienza con algo más, heredará las variables exportadas por su proceso progenitor. De modo que si tu emulador de terminar ejecuta fish, y exporta | ¡Esto también opera a la inveersa! Si fish comienza con algo más, heredará las variables exportadas por su proceso progenitor. De modo que si tu emulador de terminar ejecuta fish, y exporta | ||
- | '' | + | '' |
Las variables exportadas pueden ser locales, globales o universales; | Las variables exportadas pueden ser locales, globales o universales; | ||
Línea 334: | Línea 330: | ||
set os (uname) | set os (uname) | ||
- | echo $os | + | echo $so |
Linux | Linux | ||
</ | </ | ||
Línea 380: | Línea 376: | ||
echo ¡fish; echo es un pescado | echo ¡fish; echo es un pescado | ||
- | # or | + | # o |
echo fish | echo fish | ||
echo es un pescado! | echo es un pescado! | ||
Línea 422: | Línea 418: | ||
</ | </ | ||
- | ==== Conditionales | + | ==== Condicionales |
Línea 432: | Línea 428: | ||
else if grep bash /etc/shells | else if grep bash /etc/shells | ||
echo " | echo " | ||
+ | else if grep ksh /etc/shells | ||
+ | echo "¡Me pesqué un korn-alito!" | ||
else | else | ||
- | echo "No pesqué | + | echo "No pesqué |
end | end | ||
</ | </ | ||
Línea 440: | Línea 438: | ||
<code bash> | <code bash> | ||
- | if test " | + | if test " |
- | echo FLOUNDER | + | echo CORNALITO |
end | end | ||
- | # or | + | # o |
- | if test "$number" -gt 5 | + | if test "$numero" -gt 5 |
- | echo $number | + | echo $cantidad |
else | else | ||
- | echo $number | + | echo $cantidad |
end | end | ||
Línea 511: | Línea 509: | ||
=== funciones incorporadas === | === funciones incorporadas === | ||
- | N_, abbr, alias, bg, cd, cdh, contains_seq, | + | //N_//, //abbr//, //alias//, //bg//, //cd//, //cdh//, //contains_seq//, //dirh//, //dirs//, //disown//, //down-or-search//, //edit_command_buffer//, //export//, //fg//, //fish_add_path//, //fish_breakpoint_prompt//, //fish_clipboard_copy//, //fish_clipboard_paste//, //fish_config//, //fish_default_key_bindings//, //fish_default_mode_prompt//, //fish_git_prompt//, //fish_hg_prompt//, //fish_hybrid_key_bindings//, //fish_indent//, //fish_is_root_user//, //fish_job_summary//, //fish_key_reader//, //fish_md5//, //fish_mode_prompt//, //fish_npm_helper//, //fish_opt//, //fish_print_git_action//, //fish_print_hg_root//, //fish_prompt//, //fish_sigtrap_handler//, //fish_svn_prompt//, //fish_title//, //fish_update_completions//, //fish_vcs_prompt//, //fish_vi_cursor//, //fish_vi_key_bindings//, //funced//, //funcsave//, //grep//, //help//, //history//, //hostname//, //isatty//, //kill//, //la//, //ll//, //ls//, //man//, //nextd//, //open//, //popd//, //prevd//, //prompt_hostname//, //prompt_pwd//, //psub//, //pushd//, //realpath//, //seq//, //setenv//, //suspend//, //trap//, //type//, //umask//, //up-or-search//, //vared//, //wait//. |
Podrás ver el origen de cualquiera de las funciones pasando su nombre a funcions: | Podrás ver el origen de cualquiera de las funciones pasando su nombre a funcions: | ||
Línea 594: | Línea 592: | ||
- | $PATH is an environment | + | '' |
- | Fish takes care to set $PATH to a default, but typically it is just inherited from fish’s parent process and is set to a value that makes sense for the system - see Exports. | + | Fish se encargará de definir '' |
- | To prepend | + | Para prefijar |
<code bash>set PATH / | <code bash>set PATH / | ||
- | To remove | + | Para remover |
<code bash>set PATH (string match -v / | <code bash>set PATH (string match -v / | ||
- | For compatibility with other shells and external commands, '' | + | Por razones de compatibilidad con otras shell y comandos externos, el '' |
<code bash> | <code bash> | ||
echo " | echo " | ||
Línea 613: | Línea 610: | ||
</ | </ | ||
- | and it will be exported like that, and when fish starts it splits the $PATH it receives into a list on colon. | + | ...de este será exportado de dicha manera, y cuando Fish comience dividirá el '' |
- | You can do so directly in config.fish, | + | Puedes hacerlo directamente en '' |
- | A faster way is to use the fish_add_path | + | Una manera más rápida es usar la función '' |
<code bash> | <code bash> | ||
- | The advantage is that you don’t have to go mucking around in files: just run this once at the command line, and it will affect the current session and all future instances too. You can also add this line to config.fish, | + | La ventaja reside en que no tendrás que ir editando ficheros de confuración. Simplemente escribe esto una vez en la línea de comandos, y afectará tanto la sesión actual como todas las instancias futuras. También puedes agregar esta línea al '' |
- | Or you can modify | + | O puedes modicar '' |
- | Startup (Where’s .bashrc?) | + | |
- | Fish starts by executing commands in '' | + | ==== Inicio (¿dónde está .bashrc?) ==== |
- | It is possible to directly create functions and variables | + | Fish inicia ejecutando los comandos dispuestos en '' |
+ | |||
+ | Es posible crear firectamente funciones y variables | ||
<code bash> | <code bash> | ||
Línea 640: | Línea 638: | ||
</ | </ | ||
- | However, it is more common and efficient to use autoloading functions and universal | + | Sin embargo, lo más eficiente y común es usar funciones de autocargado y variables |
- | If you want to organize your configuration, fish also reads commands in '' | + | >Si deseas organizar tus configuraciones, fish también lee los comandos en los ficheros de extensión |
- | ==== Autoloading Functions | + | ==== Funciones de Autocarga |
- | When fish encounters a command, it attempts to autoload a function for that command, by looking for a file with the name of that command in '' | + | Cuando |
- | For example, if you wanted to have a function | + | Por ejemplo, si deseas tener una función llamada '' |
<code bash> | <code bash> | ||
Línea 657: | Línea 655: | ||
</ | </ | ||
- | This is the preferred way to define your prompt | + | Esta es también la manera preferida de definir tu //prompt// en Fish: |
<code bash> | <code bash> | ||
Línea 665: | Línea 663: | ||
end | end | ||
</ | </ | ||
+ | ==== Variables Universales ==== | ||
- | See the documentation for funced and funcsave for ways to create these files automatically, | + | Una variable |
- | + | ||
- | ==== Universal Variables ==== | + | |
- | + | ||
- | A universal variable | + | |
<code bash> | <code bash> | ||
- | set -U EDITOR | + | set -U EDITOR |
+ | </ | ||
- | Now in another | + | Ahora, en otra shell: |
+ | <code bash> | ||
echo $EDITOR | echo $EDITOR | ||
- | vim | + | nano |
</ | </ | ||
+ | |||
+ | ===== Conclusión ===== | ||
+ | |||
+ | Has aprendido las grandes diferencias puntuales del shell Fish. ¡Felicitaciones! |