<![CDATA[helloalberto.tech]]>https://helloalberto.tech/https://helloalberto.tech/favicon.pnghelloalberto.techhttps://helloalberto.tech/Ghost 5.63Sun, 24 Sep 2023 20:12:06 GMT60<![CDATA[Making the Most of Unix history Command]]>https://helloalberto.tech/unix-history-command-guide/65101b3fe36dda0e130feafdSun, 24 Sep 2023 16:14:22 GMTIf you've spent any time on the Unix command line, chances are you've come across the history command. It's that nifty tool that remembers all the commands you've typed before. But, like many things in Unix, there's more beneath the surface than meets the eye. While you might know the basics, I'm betting there's more for you to discover. This guide is designed to walk you through the nuances of the history command. By the end, not only will you understand it better, but you'll also pick up practical tips to streamline your tasks. So, even if you've used history a hundred times, stick around — you might just learn something new.

Why Use the history Command?

The history command in Unix serves as a recorder of your command-line activities. It's not just about listing old commands, but optimizing repetitive tasks, error corrections, and more. Let's deep dive into its utility.

Getting Started: Basic Commands

Initiating the history command is simple:

  • View Commands: Input history to display a list of previously executed commands.
  • Navigate Backward:Use the Up Arrow or CTRL + P to navigate to previous (older) commands
  • Navigate forward: Use the Down Arrow or CTRL + N to navigate to next (newer) commands.
  • Rerun Last Command: The !! (double exclamation mark) command lets you effortlessly redo your last action.
  • Use Specific Command Number: If you see a command in your history list numbered 123, you can rerun it by typing !123.
  • Clearing History: Keep your history concise by periodically using history -c.

Tips for Enhanced Usage

Here below some of my favorite history features:

  • Reverse-Search for commands: Press CTRL + R and start typing a portion of your command to search in previous commands. If you hit CTRL + R again, it will show you older commands.
  • Forward-Search: After you enter the Reverse-Search, you can search for newer commands by pressing CTRL + S. So by using CTRL + R and CTRL + S you will search back and forth in your history.
  • Preview Commands: !123:p displays the 123rd command without immediately executing it.
  • Tagging: Use comments starting with # to tag specific commands. This is a handy technique to annotate certain commands. It can be invaluable, especially when you revisit your command history and wonder why a particular command was executed, or to search for commands that are hard to remember.

For example here we are tagging our tar command with a # BACKUP tag:

tar -czvf backup.tar.gz /path/to/directory # BACKUP

You can then search for this command with:

history | grep "# BACKUP"

Or with the reverse-search as seen before by pressing CTRL + R and start typing your tag # BACKUP:

(reverse-i-search)`# BACKUP': tar -czvf backup.tar.gz /path/to/directory # BACKUP

Tweaks and Settings for Your Command History

Here are some of the settings that you can apply to personalize your history behavior.

History Size: To control the number of stored commands, add these two lines to your, .bashrc or .zshrc file:

export HISTFILESIZE=5000
export HISTSIZE=5000
If you want to better understand the difference between the two modifiers, I suggest to read the following Stack Overflow answer:
bash HISTSIZE vs. HISTFILESIZE?
What is the difference in HISTSIZE vs. HISTFILESIZE? They are used to extend bash history beyond the default 500 lines. There seems to be a lack of clarity here and in other forums about why they are

Excluding Specific Commands: HISTIGNORE for Bash or HISTORY_IGNORE for Zsh, are useful for preventing frequent or sensitive commands from being stored in the history. Just specify a list of patterns to be excluded from the command history.

For Bash: add the following line to your .bashrc file:

export HISTIGNORE="ls:clear:exit"

For Zsh: add this line to your .zshrc file:

export HISTORY_IGNORE="ls|clear|exit"
Please note the different separators: a colon : for the HISTIGNORE and a pipe | for the HISTORY_IGNORE.

Excluding Commands that start with a space: As an alternative to the HISTIGNORE / HISTORY_IGNORE above, you can use the HISTCONTROL for Bash or HIST_IGNORE_SPACE for Zsh, so that every time you add a space at the beginning of a command, it will not go to the history.

For Bash: add this line to your .bashrc:

export HISTCONTROL=ignorespace

For Zsh: add this line to your .zshrc file:

setopt HIST_IGNORE_SPACE

Exclude Duplicate commands: You can avoid saving a command to the history if it's the same as the last command you entered. In simpler terms, it prevents duplicate entries from appearing one after the other in your command history.

For Bash: add this line to your .bashrc file:

export HISTCONTROL=ignoredups

For Zsh: add this line to your .zshrc file:

setopt HIST_IGNORE_DUPS

Note that in Bash, ignoreboth is used when we want to use both ignorespace and ignoredups so, the following line

export HISTCONTROL=ignoreboth

is the same as:

export HISTCONTROL=ignorespace:ignoredups

Add Timestamps to your history: If you want to store timestamps with commands use the HISTTIMEFORMAT and HIST_STAMPS modifiers for Bash and Zsh, respectively.

For Bash: add this line in your .bashrc file:

export HISTTIMEFORMAT="%F %T: "

For Zsh: add this line to your .zshrc file:

HIST_STAMPS="%F %T: "

Change history file location: The default history file location is:

    • .bash_history for Bash shells
    • .zsh_history for Zsh shells
    • if it's not either of these above, you can check yours with echo $HISTFILE

If you want to change the defaults, just add the following line to your .bashrc or .zshrc file so that your history will be written to a different file. In our example here below we are changing it to a file named .my_custom_history inside your home directory:

export HISTFILE=~/.my_custom_history

Apply your settings immediately: After making changes to your .bashrc or .zshrc, you'll need to source the file for the changes to take effect in your current shell session. This allows you to immediately see and use any changes you've made without having to close and reopen your terminal or start a new shell session.

Here's how you can do it:

For .bashrc:

source ~/.bashrc

or simply:

. ~/.bashrc

For .zshrc:

source ~/.zshrc

or:

. ~/.zshrc

Conclusion

The history command in Unix is more than just a recap of what you've done—it's a handy feature that can boost your productivity on the command line. With the tips from this guide, you're better equipped to use history to its fullest. Give it a try, and see how it simplifies your Unix tasks.

]]>
<![CDATA[How to use Quick Notes on macOS]]>https://helloalberto.tech/how-to-use-quick-notes-on-macos/65073864e36dda0e130fea1bSun, 17 Sep 2023 19:57:15 GMTQuick note window

For about a year now, I've been using the Quick Notes feature on my Mac, a tool that's as straightforward as it is useful. I can't recall exactly when Apple introduced this feature or in which macOS version it debuted, but I can say it's become indispensable for my daily workflow. If you haven't yet incorporated Quick Notes into your routine or you're looking to optimize its usage, this guide is for you.

What Is Quick Notes?

Quick Notes is a built-in macOS feature that streamlines the note-taking process. It allows you to jot down information without needing to switch out of your current application. All notes taken this way are saved in a specific folder within the Notes app, where they can be edited further. Let's dig deep into its capabilities and how you can maximize its benefits.

Creating a Quick Note: The Basics

You can create a Quick Note using either a keyboard shortcut or a hot corner of your screen:

  1. Keyboard Shortcut: Simply press the Fn (Globe) key along with the letter Q.
  2. Hot Corners: Hover your mouse pointer to the pre-set lower-right corner of your screen and click on the note icon that appears.

If the Hot Corner does not activate the Quick Note, first check the option is selected in your System Settings -> Desktop and Dock -> Hot Corners

Hot Corner settings in macOS

Then select Quick Note on one of your available corners

Hot Corner selection

Both methods offer immediate access to the Quick Notes feature, making it convenient to take notes during web browsing sessions, video conferences, or any other tasks you are engaged in.

Create a new Quick Note each time
Tip: If you prefer having a new Quick Note each time instead of resuming the last one, go to Notes -> Preferences and deselect the Always resume to last Quick Note option.

The real utility of Quick Notes shines when you're working within the Safari browser:

  1. Web Links: To add a web link to your Quick Note, click on the 'Share' button within your Safari window, and then select Add to Quick Note.
Quick Note from the Share option in Safari
  1. Page Highlights: Want to remember a specific piece of text? Simply highlight it, right-click, and then choose Add to Quick Note. The text will remain highlighted even when you revisit the webpage later.
Highlight text in Safari and create a Quick Note

By using these features, you transform your Quick Notes into a dynamic repository of information that goes beyond simple text entries.

Managing Quick Notes

Managing Quick Notes is as easy as managing any other note on the Notes app. However, given that Quick Notes are meant to be, well, quick, it's quite common to have them pile up. Here are some organizational tips:

  • Tagging: Use tags to categorize your Quick Notes. Just type # followed by your tag. Your tags will then appear within your Folders
  • Searching: Use the search function to find the note you are looking for easily.

Advanced Features

  • Tables: Just like in the main Notes app, you can add tables to your Quick Notes to better structure your information.
  • Checklists: For task-oriented notes, make use of checklists within Quick Notes.
  • Attachments: Believe it or not, Quick Notes can contain attachments like photos and scanned documents.

Action Plan

To really get the most out of Quick Notes, you need an action plan:

Define Your Use-Case: What kind of information will you primarily be capturing?

    • A shopping list to capture items you need to buy on your next trip to the grocery store. This is the most common use I suppose.
    • Reading Lists: a collection of books, articles, or papers you plan to read, possibly organized by topic or priority (I recommend to use tags here).
    • Travel Itineraries: Flight details, hotel reservations, must-see locations, and daily activity plans for upcoming trips.
    • Idea Journal: A repository of ideas for stories, poems, or other creative projects.
    • Music Playlist: Lists of songs or compositions for different moods, activities, or events.
    • Research Notes: Summaries of academic papers, books, or lectures relevant to your research.

Testing: Experiment with Quick Notes in different scenarios—while reading articles, attending meetings, and so on.

Regular Cleanup: Make it a habit to periodically go through your Quick Notes to categorize, tag, or delete as necessary.

Final Thoughts

The Quick Notes feature in macOS is more than just a convenient tool; it's a dynamic system for managing quick bits of information that otherwise could easily get lost. By following this guide, you'll be better equipped to make Quick Notes a truly effective part of your productivity toolkit.

]]>
<![CDATA[Coming Soon: A Blog for Tech Enthusiasts and Professionals]]>Hello everyone,

I'm excited to announce that I'll be launching a blog focused on both software development and systems engineering. This platform aims to bridge the gap between these two essential areas in tech.

What Can You Expect?

  • Practical Guides: Step-by-step guides to demystify complex technical
]]>
https://helloalberto.tech/coming-soon/65049b60e36dda0e130fe7e8Fri, 15 Sep 2023 17:58:56 GMT

Hello everyone,

I'm excited to announce that I'll be launching a blog focused on both software development and systems engineering. This platform aims to bridge the gap between these two essential areas in tech.

What Can You Expect?

  • Practical Guides: Step-by-step guides to demystify complex technical topics.
  • Q&A: A series where we address questions from you, the readers. The aim is to encourage a culture of ongoing learning and curiosity.
  • Tips and Tricks: Discover how to be more efficient with your technology, both at work and in your personal life.

Who Is This For?

  • Software Developers
  • Systems Engineers
  • Anyone interested in gaining a nuanced understanding of technology

Why this Blog?

  • I've been working in technology for many years and can't wait to share insights, answer your questions, and learn together. Let's make tech less intimidating and more accessible for everyone.

See you soon!

]]>