{"id":1529,"date":"2016-11-13T11:50:00","date_gmt":"2016-11-13T17:50:00","guid":{"rendered":"http:\/\/linuxitos.com\/main\/crear-alias-en-zsh\/"},"modified":"2016-11-13T11:50:00","modified_gmt":"2016-11-13T17:50:00","slug":"crear-alias-en-zsh","status":"publish","type":"post","link":"https:\/\/linuxitos.com\/main\/crear-alias-en-zsh\/","title":{"rendered":"Crear alias en ZSH"},"content":{"rendered":"<div dir=\"ltr\" style=\"text-align: left;\">\n<div style=\"text-align: center;\"><a href=\"http:\/\/2.bp.blogspot.com\/-nvNYZ8o6B78\/WCiVfKu7i3I\/AAAAAAAAD10\/gMXh-NYAsRsfiut6EpQ4HhD-DhAmqgewgCK4B\/s1600\/Peek%2B2016-11-13%2B10-30.gif\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/2.bp.blogspot.com\/-nvNYZ8o6B78\/WCiVfKu7i3I\/AAAAAAAAD10\/gMXh-NYAsRsfiut6EpQ4HhD-DhAmqgewgCK4B\/s1600\/Peek%2B2016-11-13%2B10-30.gif\" \/><\/a><\/div>\n<div style=\"text-align: justify;\"><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Algo que me disgusta hasta cierto punto al usar la terminal en linux, es la tediosa tarea de memorizar un infinito n\u00famero de comandos, &nbsp;y peor a\u00fan si este es muy extenso, si bien es cierto que, es necesario o es una buena practica memorizarlos, pero sin duda alguna es bastante complicado.<\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Una manera de evitar memorizar sentencias extremadamente largas, es la creaci\u00f3n de \u00abalias\u00bb, los alias simplifican una expresi\u00f3n de comandos, es decir, al alias le asignamos un conjunto de expresiones que usen comandos complicados de recordar, y en ves de escribir todo la expresi\u00f3n completa de comandos, lo \u00fanico que debemos escribir, es el alias.<\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Yo uso la siguiente instrucci\u00f3n para liberar memoria ram y limpiar la cach\u00e9 <b>sudo sync &amp;&amp; sudo sysctl -w vm.drop_caches=3<\/b>, buscar esa instrucci\u00f3n en el historial de comandos de la terminal, puede ser una opci\u00f3n, pero no siempre quiero estar buscando, ahora memorizar los comandos y el orden de los mismos, tampoco es lo m\u00e1s factible y para simplificarlo se crean alias.<\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Cuando se usa un interprete de comandos ajeno a bash (es el que viene por defecto en las distros linux), es tan simple como utilizar el comando alias para crear uno:<\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Ejemplo:<\/span><\/div>\n<pre style=\"background: none 0% 0% no-repeat scroll rgb(0, 0, 0); border-radius: 3px; border: 1px solid rgb(0, 0, 0); font-family: &quot;Droid Sans Mono&quot;, Consolas, monospace; font-size: 13px; line-height: 20px; margin: 8px 15px; max-width: 100%; opacity: 0.85; outline: 0px; overflow: auto; padding: 9.5px; text-shadow: none; vertical-align: baseline; white-space: pre-wrap; word-break: break-all; word-wrap: break-word;\"><span style=\"color: white;\">alias limpiar = \"sudo sync &amp;&amp; sudo sysctl -w vm.drop_caches=3\"<\/span><\/pre>\n<div><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Sin embargo, cuando usas alguno externo, por ejemplo ZSH, las cosas no son tan complicadas, solo basta agregar la misma l\u00ednea, pero al final del archivo <b>.zshrc<\/b>&nbsp;que est\u00e1 oculto en la carpeta personal de tu usuario. Por lo tanto damos&nbsp;<\/span><kbd style=\"background: rgb(238, 238, 238); border-color: rgb(204, 204, 204) rgb(187, 187, 187) rgb(119, 119, 119); border-image: initial; border-style: solid; border-width: 1px 3px 3px; color: #333333; font-family: &quot;courier new&quot;, monospace; font-size: 18px; font-stretch: normal; letter-spacing: -0.5px; line-height: normal; margin: 0px; outline: 0px; padding: 1px 6px; position: relative; top: -2px; vertical-align: baseline; white-space: nowrap;\">CTRL<\/kbd><span style=\"background-color: white; border: 0px; color: #222222; font-family: &quot;exo 2&quot;, &quot;open sans&quot;, sans-serif; font-size: 22px; letter-spacing: -0.5px; margin: 0px; outline: 0px; padding: 0px; vertical-align: baseline;\">+<\/span><kbd style=\"background: rgb(238, 238, 238); border-color: rgb(204, 204, 204) rgb(187, 187, 187) rgb(119, 119, 119); border-image: initial; border-style: solid; border-width: 1px 3px 3px; color: #333333; font-family: &quot;courier new&quot;, monospace; font-size: 18px; font-stretch: normal; letter-spacing: -0.5px; line-height: normal; margin: 0px; outline: 0px; padding: 1px 6px; position: relative; top: -2px; vertical-align: baseline; white-space: nowrap;\">h<\/kbd><span style=\"font-size: large;\">&nbsp;para desocultar los archivos. &nbsp;<\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Una vez localizado, lo abrimos y agregamos la l\u00ednea, tal y como se ve en la imagen siguiente:<\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: center;\"><span style=\"font-size: large;\"><a href=\"http:\/\/1.bp.blogspot.com\/-1919kT5vTUg\/WCiZL-h7i-I\/AAAAAAAAD2A\/-MZdu0wNp4AIrkgKrZt2qx7JNYSiZr6oQCK4B\/s1600\/Captura%2Bde%2Bpantalla%2Bde%2B2016-11-13%2B10-46-49.png\"><img decoding=\"async\" border=\"0\" src=\"https:\/\/1.bp.blogspot.com\/-1919kT5vTUg\/WCiZL-h7i-I\/AAAAAAAAD2A\/-MZdu0wNp4AIrkgKrZt2qx7JNYSiZr6oQCK4B\/s1600\/Captura%2Bde%2Bpantalla%2Bde%2B2016-11-13%2B10-46-49.png\" \/><\/a><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Ahora, solo queda reiniciar la terminal y ya se pueden utilizar los alias.<\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\"><br \/><\/span><\/div>\n<div style=\"text-align: justify;\"><span style=\"font-size: large;\">Y as\u00ed es como se crean los alias en ZSH. Cada quien tiene sus gustos, configuraciones, etc, por lo tanto esto solo es una idea, para los que usamos ZSH como interprete de comandos.<\/span><\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Algo que me disgusta hasta cierto punto al usar la terminal en linux, es la tediosa tarea de memorizar un infinito n\u00famero de comandos, &nbsp;y peor a\u00fan si este es muy extenso, si bien es cierto que, es necesario o es una buena practica memorizarlos, pero sin duda alguna es bastante complicado. Una manera de [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[331,221,7,332,219],"tags":[],"class_list":["post-1529","post","type-post","status-publish","format-standard","hentry","category-alias","category-comandos","category-fedora","category-interprete","category-zsh"],"_links":{"self":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts\/1529","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/comments?post=1529"}],"version-history":[{"count":0,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/posts\/1529\/revisions"}],"wp:attachment":[{"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/media?parent=1529"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/categories?post=1529"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxitos.com\/main\/wp-json\/wp\/v2\/tags?post=1529"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}