How can I save or bookmark terminal commands for easy access?

0
1
Asked By CuriousCactus123 On

I found a command to check battery health: `upower -i /org/freedesktop/UPower/devices/battery_BAT1`. I'm looking for a way to save or bookmark this command so I can easily run it in the terminal later. Any suggestions?

3 Answers

Answered By ScriptMaster9 On

You could also create a shell script for your command. Save it in a directory that's in your `$PATH`, then you can run it just by typing the script name. For example, name the script something like `check_battery.sh` with the command inside, and it'll make it much quicker to access!

Answered By BashGuru77 On

If you want to keep it simple, you can rely on your bash history too. It'll automatically store all the commands you've run, as long as it's set up properly. For easier navigation, check out tools like `fzf` that enhance searching your command history!

UserFriendly101 -

Good call! Using `fzf` really brings your history to life. The search feature makes finding past commands super quick!

Answered By TechieSam42 On

A great way to do this is to create an alias in your bash configuration file. Just add something like `alias power='upower -i /org/freedesktop/UPower/devices/battery_BAT1'` to your `~/.bashrc`. Then, whenever you type `power`, it will run that command for you!

Related Questions

LEAVE A REPLY

Please enter your comment!
Please enter your name here

This site uses Akismet to reduce spam. Learn how your comment data is processed.