You are Here:
Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section



Creating aliases in fish and bash shell

Author (Read 10693 times)

0 Members and 1 Guest are viewing this topic.

Creating aliases in fish and bash shell
« Reply #1 on: August 01, 2019, 09:06:30 PM »
 

Moltke

  • Platinum Level Poster
  • **********
  • 1134
    Posts
  • Reputation: 126
  • Linux Lite Member
    • View Profile

  • CPU: amd athlon 64 x2

  • MEMORY: 4Gb

  • VIDEO CARD: amd radeon hd 6750

  • Kernel: 5.x
Hi everyone! Hope you're all having a nice life! :)

Today I'd like to share with you how to create your aliases in fish as well as in bash shell. As some of you probably already know, aliases are like "nicknames" for those commands, often long, we use the most and by "aliasing" them we make them short. In bash, one creates aliases like this
Code: [Select]
alias install="sudo apt-get install" then we hit enter and next time instead of typing "sudo apt-..." simply typing install will do the same task, which is install a given package. However, this is temporary, if you want to make your aliases permanent and available across boots, you have to create a file called .bash_aliases
Code: [Select]
nano .bash_aliases and add your aliases there. Once you've added them open a terminal and do
Code: [Select]
. .bash_aliases then hit enter, this will make the aliases available inmediately and across boots. You could also add them in the file .bashrc but as far as I read the former method seems to be the most appropriate.

Now, in fish aliases are created in a different way, for one they're not called aliases but functions and just like with bash aliases you can create them for temporary use or add them in the file .config/fish/config.fish if it doesn't exist create it
Code: [Select]
nano .config/fish/config.fish once you've created the file start adding your functions, like so:
Code: [Select]
function install
    sudo apt-get install %argv
end
Add as many as you wish/need, once you've finished adding your functions type
Code: [Select]
. .config/fish/config.fish and hit enter to make them available for use inmediately.

Aliases are time  savers since we don't have to type long commands once and again over and over. Hope you've liked the post and found it useful. :)

Cheers!
« Last Edit: August 02, 2019, 03:50:36 PM by Moltke »
Without each others help there ain't no hope for us :)
Need a translation service? https://www.deepl.com/es/translator
 

 

-->
X Close Ad

Linux Lite 6.6 FINAL Released - Support for 22 Languages Added - See Release Announcement Section