terminal Archives - ProdSens.live https://prodsens.live/tag/terminal/ News for Project Managers - PMI Sun, 24 Mar 2024 02:20:48 +0000 en-US hourly 1 https://wordpress.org/?v=6.5.5 https://prodsens.live/wp-content/uploads/2022/09/prod.png terminal Archives - ProdSens.live https://prodsens.live/tag/terminal/ 32 32 Warp terminal on WSL is AMAZING https://prodsens.live/2024/03/24/warp-terminal-on-wsl-is-amazing/?utm_source=rss&utm_medium=rss&utm_campaign=warp-terminal-on-wsl-is-amazing https://prodsens.live/2024/03/24/warp-terminal-on-wsl-is-amazing/#respond Sun, 24 Mar 2024 02:20:48 +0000 https://prodsens.live/2024/03/24/warp-terminal-on-wsl-is-amazing/ warp-terminal-on-wsl-is-amazing

If you’re a developer working with Windows Subsystem for Linux (WSL), prepare to be amazed by Warp Terminal.…

The post Warp terminal on WSL is AMAZING appeared first on ProdSens.live.

]]>
warp-terminal-on-wsl-is-amazing

If you’re a developer working with Windows Subsystem for Linux (WSL), prepare to be amazed by Warp Terminal. My journey with Warp began by following the footsteps of @ljtruong, updating Ubuntu, and ensuring all packages were up to date. The real magic started when I downloaded and installed the Warp Terminal.

Installation: A Breeze
The process was straightforward. I grabbed the .deb file directly from Warp’s official download page and installed it within WSL using the following command:

sudo dpkg -i warp-terminal_.deb

Execution: Smooth and Seamless
Running Warp Terminal was as simple as setting a couple of environment variables. I added these lines to my ~/.bash_profile:

export WARP_ENABLE_WAYLAND=1
export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA
export BROWSER=google-chrome

With these variables set, launching Warp Terminal was just a matter of typing warp-terminal into the console.

Authentication: Secured and Swift
To obtain the authentication token, I installed Google Chrome in WSL. Downloading and installing Chrome was a quick two-step process:

wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo apt -y install ./google-chrome-stable_current_amd64.deb

After setting Chrome as the default browser and adding export BROWSER=google-chrome to my profile config, I logged into Warp’s remote login page. A few clicks later, Warp Terminal synced with the authentication token, and I was ready to go.

The Result: Beyond Expectations
The result was nothing short of spectacular. Warp Terminal on WSL is not just another terminal; it’s a testament to how seamless development on Windows can be. It’s fast, it’s efficient, and it integrates flawlessly with the graphical environment, thanks to the Wayland support.

For developers looking to streamline their workflow, Warp Terminal is a must-try. It’s not just a tool; it’s an experience that elevates your coding sessions to new heights.

Feel free to adjust the content to better fit your voice and experience. Happy blogging!

The post Warp terminal on WSL is AMAZING appeared first on ProdSens.live.

]]>
https://prodsens.live/2024/03/24/warp-terminal-on-wsl-is-amazing/feed/ 0
Warp: The Supercharged Terminal for Developers https://prodsens.live/2024/03/09/warp-the-supercharged-terminal-for-developers/?utm_source=rss&utm_medium=rss&utm_campaign=warp-the-supercharged-terminal-for-developers https://prodsens.live/2024/03/09/warp-the-supercharged-terminal-for-developers/#respond Sat, 09 Mar 2024 14:20:17 +0000 https://prodsens.live/2024/03/09/warp-the-supercharged-terminal-for-developers/ warp:-the-supercharged-terminal-for-developers

Imagine a command line that’s actually easy to use, helps you get things done faster, and even lets…

The post Warp: The Supercharged Terminal for Developers appeared first on ProdSens.live.

]]>
warp:-the-supercharged-terminal-for-developers

Imagine a command line that’s actually easy to use, helps you get things done faster, and even lets your team work together better. That’s what Warp Terminal promises. Let’s explore this interesting tool and see what makes it so special.

Like a Text Editor for Your Commands

Forget that scary screen full of endless lines of text! Warp makes your terminal feel friendly. It gives your commands space to breathe and uses colors to help you quickly find the important stuff.

The best part is how you work with your old commands. Instead of trying to remember and retype everything, you can scroll back through them like you would in a normal document. Need that command from a while ago? Just scroll, find it, copy, and paste – it’s that easy!

Your Smart Command-Line Helper

Warp has a superpower – it can guess what you’re trying to type! While you’re putting in a command, it will suggest options to complete it, saving you time and brain power spent on remembering the exact details.

Image description
But Warp doesn’t just help you type commands faster. It can also explain errors in a way you can understand. If something goes wrong, Warp can point you to reasons why and even offer ways to fix it.

Think of it like having a smart friend always looking over your shoulder when you’re working in the terminal!

Warp Blocks: Your Command-Line Power Tools

Warp lets you build something called “Blocks.” Imagine them like little boxes full of commands. Blocks can do all sorts of things:

  • Little Shortcuts: Turn a long command you use all the time into a short, easy-to-remember word.

  • Big Time Savers: Put a bunch of steps together into a single Block and make tricky tasks quick to do.

  • Recipe Books: Write down how to do important things in Blocks so you never forget the steps.

Teamwork Magic with Warp Drive

Image description
Here’s where things get really exciting. Warp Drive lets you share your Blocks with your whole team. Imagine everyone having the same useful tools! Here’s what you can do:

  • Newbies Get a Boost: Give new teammates a collection of Blocks to help them get work done right away.

  • Sharing is Caring: If you build a cool Block, share it, and maybe your coworkers will share with you too!

More Reasons to Love Warp

  • Make it Yours: Change the colors, fonts, and all that good stuff so Warp feels like your own comfy workspace.

  • Helpful Community: Warp is still pretty new, and lots of people are excited about it. This means cool new Blocks, ideas, and ways to make Warp even better are always being shared.

Should You Give Warp a Try?

If you spend any time working in the terminal, Warp is worth checking out. It might take a bit to get used to if you’re coming from a regular terminal, but the time you save and the cool things you can do will make it worth your while.

How to Start

  1. Visit Warp’s Website: warp.dev

  2. Get the App: Download the version for your computer (they have it for Mac and Linux right now)

  3. Play Around! Give the smart suggestions a try, make a simple Block, and change up the colors to make Warp your own.

Warp is a fresh new way to use the command line. Its friendly design, smart help, and amazing team features make it one exciting tool for any developer!

The post Warp: The Supercharged Terminal for Developers appeared first on ProdSens.live.

]]>
https://prodsens.live/2024/03/09/warp-the-supercharged-terminal-for-developers/feed/ 0
How to Force Quit Unresponsive Applications via CLI on macOS https://prodsens.live/2024/02/11/how-to-force-quit-unresponsive-applications-via-cli-on-macos/?utm_source=rss&utm_medium=rss&utm_campaign=how-to-force-quit-unresponsive-applications-via-cli-on-macos https://prodsens.live/2024/02/11/how-to-force-quit-unresponsive-applications-via-cli-on-macos/#respond Sun, 11 Feb 2024 06:20:18 +0000 https://prodsens.live/2024/02/11/how-to-force-quit-unresponsive-applications-via-cli-on-macos/ how-to-force-quit-unresponsive-applications-via-cli-on-macos

If you’re working on a macOS system and encounter an application that’s not responding, you know how frustrating…

The post How to Force Quit Unresponsive Applications via CLI on macOS appeared first on ProdSens.live.

]]>
how-to-force-quit-unresponsive-applications-via-cli-on-macos

If you’re working on a macOS system and encounter an application that’s not responding, you know how frustrating it can be. While the graphical interface offers ways to force quit applications, sometimes you may need or prefer to do this from the command line interface (CLI). Whether you’re remote accessing a system, prefer using the terminal, or are in a situation where the GUI is not accessible, knowing how to handle this via CLI can be incredibly useful. Here’s a step-by-step guide on how to force quit unresponsive applications using the command line on macOS.

1. Finding the Process ID (PID)

The first step in forcing an application to quit is identifying the process ID (PID) of the application. The PID is a unique number that macOS uses to refer to each running process. There are a couple of ways to find the PID of an unresponsive application:

Using ps aux:

  • Open the Terminal application.
  • Type ps aux and press Enter. This command lists all running processes on the system.
  • Look through the list for the name of the unresponsive application. Next to it, you’ll see a number, which is its PID.

Using pgrep:

  • Alternatively, you can use the pgrep command for a quicker way to find the PID. Simply type pgrep [application name], replacing [application name] with the name of the program. For example, pgrep TextEdit will return the PID for TextEdit if it’s running.

2. Force Quitting with the kill Command

Once you have the PID, you can proceed to force quit the application using the kill command.

  • In Terminal, type kill [PID], replacing [PID] with the actual process ID of the application you want to quit. For example, kill 12345.

  • If the application doesn’t quit with the standard kill command, you can use a stronger signal, -9, to force quit. Type kill -9 [PID], for example, kill -9 12345. This sends a SIGKILL signal, which immediately terminates the process.

3. Using pkill to Directly Force Quit

If you prefer not to look up the PID, you can use the pkill command to force quit an application by its name.

  • Simply type pkill [application name]. For instance, pkill TextEdit would force quit TextEdit.

Caution

While force quitting applications can be necessary, it should be done with caution. Unsaved data may be lost, and there’s always a slight risk of causing system instability. Always attempt to allow the application to respond on its own or try to close it normally before resorting to force quitting.

Conclusion

Understanding how to manage unresponsive applications through the CLI can be a powerful addition to your troubleshooting toolkit on macOS. Whether you’re a developer, system administrator, or just prefer using the terminal, these commands offer a quick and effective way to regain control over your system when applications freeze or become unresponsive.

Remember, with great power comes great responsibility. Use these commands wisely and always ensure you have saved your work before force quitting any application.

The post How to Force Quit Unresponsive Applications via CLI on macOS appeared first on ProdSens.live.

]]>
https://prodsens.live/2024/02/11/how-to-force-quit-unresponsive-applications-via-cli-on-macos/feed/ 0
Finding the right macOS `defaults` command https://prodsens.live/2023/10/01/finding-the-right-macos-defaults-command/?utm_source=rss&utm_medium=rss&utm_campaign=finding-the-right-macos-defaults-command https://prodsens.live/2023/10/01/finding-the-right-macos-defaults-command/#respond Sun, 01 Oct 2023 04:24:36 +0000 https://prodsens.live/2023/10/01/finding-the-right-macos-defaults-command/ finding-the-right-macos-`defaults`-command

Automating the setup of a clean macOS install is a lot easier when you know which keys to…

The post Finding the right macOS `defaults` command appeared first on ProdSens.live.

]]>
finding-the-right-macos-`defaults`-command

Automating the setup of a clean macOS install is a lot easier when you know which keys to edit via the defaults command. Since there’s no official listing of all the keys, there are places online that give you the most commonly used ones and try to stay up to date with the names of the keys in the latest release of macOS, with varying degrees of success. The best way is to grab the correct names directly from your Mac.

Note: First, make sure your terminal has Full Disk Access in System Settings > Privacy and Security.

The format to edit your macOS preferences is
defaults write $DOMAIN $KEY -$TYPE $VALUE

And you can list all the domains with
defaults domains | tr ', ' 'n'

You can figure out the correct domain and key names by comparing the output of defaults read before and after manually changing a setting in the UI. You can also specify a domain to narrow down the output but it’s not required so don’t worry if you’re not sure which domain is affected by the setting you’re interested in. Remember to kill any affected apps to apply the changes.

Example:

defaults read com.apple.finder > before.txt
# Change Finder Settings in the UI
# to clear "Show warning before changing an extension" 
defaults read com.apple.finder > after.txt
diff before.txt after.txt
# <     FXEnableExtensionChangeWarning = 1;
# ---
# >     FXEnableExtensionChangeWarning = 0;

Now check the type and you got a command you can add to any automation you wish.

defaults read-type com.apple.finder FXEnableExtensionChangeWarning
# Type is boolean
defaults write com.apple.finder FXEnableExtensionChangeWarning -bool false
killall Finder 2> /dev/null

If you can’t find a key where you expected it, remove the domain from your query or check the global domain. This one affects Finder but it’s in the global domain instead of com.apple.finder.

defaults read "Apple Global Domain" AppleShowAllExtensions
# 1
defaults read-type "Apple Global Domain" AppleShowAllExtensions
# Type is boolean

Other commands to try:

defaults help
defaults find $WORD
defaults read com.apple.dock | grep wvous # Hot Corners

Want an example of a setup script? Check out mine.

The post Finding the right macOS `defaults` command appeared first on ProdSens.live.

]]>
https://prodsens.live/2023/10/01/finding-the-right-macos-defaults-command/feed/ 0
The Complete Guide to Becoming a Web Developer: Part 6 https://prodsens.live/2023/08/06/the-complete-guide-to-becoming-a-web-developer-part-6/?utm_source=rss&utm_medium=rss&utm_campaign=the-complete-guide-to-becoming-a-web-developer-part-6 https://prodsens.live/2023/08/06/the-complete-guide-to-becoming-a-web-developer-part-6/#respond Sun, 06 Aug 2023 19:25:15 +0000 https://prodsens.live/2023/08/06/the-complete-guide-to-becoming-a-web-developer-part-6/ the-complete-guide-to-becoming-a-web-developer:-part-6

Welcome back to the series “Becoming a Web Developer” part 6. If you are new here, you can…

The post The Complete Guide to Becoming a Web Developer: Part 6 appeared first on ProdSens.live.

]]>
the-complete-guide-to-becoming-a-web-developer:-part-6

Welcome back to the series “Becoming a Web Developer” part 6. If you are new here, you can start with this list [ part 1part 2part 3part 4, part 5]. In this part, we will discuss the terminal and most used commands for web developers, and for more commands and details you can visit here.

Now, If you’re a web developer, software engineer, or just a tech enthusiast, you’ve probably used Linux commands and the terminal. But if you’re not, let’s get you to learn what are they, and why are they so important. Let’s dive in!

  • Backend? 🧐

    • What exactly is the backend?
  • Tips to Get comfortable with the Terminal
  • Listing and Path

    • The ls Command
    • The pwd Command
  • Navigation and Paths

    • The cd command
    • Relative Paths
    • Absolute Paths
  • Creating Directories (Folders)
  • The touch Command

    • Removing Files & Folders
  • More Tips and Best Practices

    • Common Mistakes and How to Avoid Them
  • Conclusion

    • Additional Resources

The terminal, also known as the command line interface (CLI), is a tool that allows us to interact with our computer using text-based commands. It’s a powerful tool that gives us direct access to the operating system and allows us to perform tasks more efficiently than we could with a graphical user interface (GUI).

Linux commands are the language we use to communicate with the terminal. This originated in the Unix operating system but is now used in many other systems, including Linux and MacOS.

So why should you, as a web developer or software engineer, care about Linux commands and the terminal? Here are a few reasons:

  1. Efficiency: Linux commands can perform complex tasks quickly and with fewer steps than a GUI.
  2. Control: The terminal gives you more control over your system. You can access and modify files that are not visible or accessible in a GUI.
  3. Scripting: Linux commands can be combined into scripts, allowing you to automate repetitive tasks.
  4. Development Tools: Many tools for developers, like Git and Node.js, are primarily used through the terminal.
  5. Troubleshooting: Understanding Linux commands can help you diagnose and fix problems on your system.

In this article, we’ll start with the basics and what you need to learn to start with Linux as a software developer or web developer.

Backend? 🧐

Before we dive into the commands and the terminal, let’s take a moment to understand what’s happening on the backend side of things. If you’re new to web development, you might be wondering,

What exactly is the backend?

In the context of web development, the ‘backend’ refers to the server side of an application. This is the part of the software that users don’t see. It’s where the magic happens: data is processed, stored, and sent back to the user. The backend is responsible for business logic, database interactions, server configuration, and much more.

Imagine you’re visiting an online store. The beautiful webpage you see, with all its images, buttons, and menus, is the ‘front end.’ It’s what you interact with. But when you click on a product to view more details or place an order, your request is sent to the ‘backend.’ The backend retrieves the product details from the database or processes your order, then sends the information back to the frontend to be displayed to you.

So, why is understanding the backend important for learning Linux commands and the terminal? Well, as a backend developer, or even a full-stack developer (someone who works on both the frontend and backend), you’ll often find yourself working in a Unix-like environment. You’ll need to navigate through your system’s directories, manipulate files, install software, and run scripts, all using the terminal. That’s why getting comfortable with Linux commands is such a crucial skill.

In the following sections, we’ll start exploring these commands, So, buckle up and get ready for an exciting journey!

Tips to Get comfortable with the Terminal

Getting comfortable with the terminal is a bit like learning to ride a bike. It might seem intimidating at first, but with practice, it becomes second nature. Here are some tips and strategies to help you become more comfortable with the terminal:

1. Practice Regularly

The best way to get comfortable with the terminal is to use it regularly. Try to incorporate it into your daily workflow. Need to create a new directory? Use mkdir. Need to move a file? Use mv. The more you use the terminal, the more familiar it will become.

2. Learn the Basics

Start with the basic commands like ls, pwd, cd, mkdir, touch, rm, and cp. Understand what they do and practice using them. Once you’re comfortable with the basics, you can move on to more advanced commands and concepts.

3. Use the man Command

The man command is your built-in manual. Use it to learn about other commands and their options. For example, man ls will show you the manual for the ls command, including a description of what it does and a list of its options.

4. Don’t Be Afraid to Make Mistakes

It’s okay to make mistakes. In fact, making mistakes is a great way to learn. If you type a command and it doesn’t work, try to figure out why. Is there a typo in the command? Are you in the right directory? Did you forget an option?

5. Customize Your Terminal

Customizing your terminal can make it more pleasant to use. You can change the colors, prompt, and even add features like auto-completion and command aliases. There are also different terminal emulators you can try, each with their own set of features.

6. Learn to Use a Text Editor

Knowing how to use a text editor from the terminal is a valuable skill. Whether it’s Vim, Emacs, or Nano, choose one and learn the basics. You’ll need this skill for editing configuration files, writing scripts, and more.

7. Explore and Have Fun

Finally, don’t forget to have fun. A terminal is a powerful tool, and learning to use it effectively can open up new possibilities. Try new commands, write scripts, and automate tasks. The more you explore, the more comfortable you’ll become.

Listing and Path

Let’s kick things off with two of the most basic yet essential Linux commands: ls and pwd. These commands are your bread and butter when it comes to navigating the terminal. They’re the equivalent of looking around and checking your map in a new city.

The ls Command

The ls command stands for ‘list’. As the name suggests, it lists the contents of a directory. When you type ls into the terminal and hit enter, it will display all the files and directories in your current location.

Here’s an example:

$ ls
Desktop    Downloads  Pictures  Documents  Music

This example, ls has listed five directories: Desktop, Downloads, Pictures, Documents, and Music.

As mentioned, ls lists the contents of a directory. But it can do much more when used with options. Let’s look at some examples:

ls -l: This option displays the contents in a ‘long format’, which includes additional information such as the file permissions, number of links, owner, group, size, and time of last modification.

$ ls -l
total 0
drwx------+ 3 YourUsername  staff   96 Mar  1 09:00 Desktop
drwx------+ 4 YourUsername  staff  128 Mar  1 09:00 Documents
drwx------+ 3 YourUsername  staff   96 Mar  1 09:00 Downloads
drwx------+ 3 YourUsername  staff   96 Mar  1 09:00 Music
drwx------+ 3 YourUsername  staff   96 Mar  1 09:00 Pictures

ls -a: This option shows all files, including hidden ones. In Unix-like systems, files that start with a dot (.) are hidden.

$ ls -a
.  ..  .bash_history  .bash_profile  Desktop  Documents  Downloads  Music  Pictures

ls -R: This option lists the contents of directories recursively, meaning it will show the contents of the directories within the current directory, and so on.

$ ls -R
.:
Desktop  Documents  Downloads  Music  Pictures

./Desktop:
file1.txt  file2.txt

./Documents:
doc1.docx  doc2.docx

./Downloads:
image1.jpg  image2.jpg

./Music:
song1.mp3  song2.mp3

./Pictures:
photo1.png  photo2.png

The pwd Command

The pwd command stands for ‘print working directory’. It tells you where you currently are in your system’s directory structure. Think of it as checking your current location on a map.

Here’s an example:

$ pwd
/Users/YourUsername

In this example, pwd has printed the path to the current directory, which is the user’s home directory.

pwd -P: This option prints the physical directory, without any symbolic links. If you’re in a directory that is a symbolic link (a file that points to another file or directory), pwd -P will show the actual directory, not the linked one.

$ pwd -P
/Users/YourUsername/ActualDirectory

In this example, even if you navigated to the directory using a symbolic link, pwd -P shows the path to the actual directory.

These two commands, ls and pwd, are your starting point for navigating the terminal. Practice using them until you’re comfortable. In the next sections, we’ll learn how to move around the directory structure and manipulate files. So, stay tuned!”

P.S. Remember, you can always use the man command to read the manual and learn more about these commands and their options. For example, man ls will show the manual for the ls command.

Changing directories is a fundamental task you’ll do in the terminal. It’s like navigating through folders in a graphical file explorer, but instead, you’re using text commands. The command to change directories in Unix-based systems is cd, which stands for “change directory”.

Let’s start with the basics. If you want to move into a directory, you type cd followed by the name of the directory. For example, if you have a directory named projects, you can move into it with:

The cd command

cd projects

Now, what if you want to move back to the previous directory? You can use .. to represent the parent directory. So to move back, you can do:

cd ..

You can also use .. to move multiple levels up. For example, cd ../.. will move two levels up.

If you want to go to your home directory, you can use the cd command without any arguments:

cd

You can also use ~ to represent your home directory. So cd ~ will also take you home.

What about if you want to go to a specific directory, no matter where you currently are? You can do this by providing the absolute path to the directory. For example:

cd /usr/local/bin

This will take you to the directory /usr/local/bin, regardless of your current directory.

Remember, the terminal is case-sensitive. So cd projects is different from cd Projects.

Also, if the directory name has spaces, you need to enclose it in quotes. For example:

cd "My Projects"

Or you can escape the space with a backslash:

cd My Projects

Relative Paths

A relative path is a path that starts from your current directory. It’s ‘relative’ to where you are right now in the file system. For example, if you’re in a directory called projects and there’s a subdirectory in it called myapp, the relative path to myapp is simply:

myapp
cd myapp
cd ..

You can use this relative path with commands like cd to move into myapp.

Relative paths can also use special directory names like . (which represents the current directory) and .. (which represents the parent directory).

Absolute Paths

An absolute path, on the other hand, is a path that starts from the root of the file system. It’s ‘absolute’ because it points to the same location, no matter where you currently are in the file system. An absolute path always starts with a /.

For example, the absolute path to a directory myapp located directly under projects in your home directory might look something like the following. You also can use this absolute path with cd to go directly to myapp, no matter your current location:

/home/username/projects/myapp
cd /home/username/projects/myapp

P.S. If you’re moving around directories close to your current location, relative paths are simpler. If you’re jumping to a directory far from your current location, absolute paths can be more direct.

Creating Directories (Folders)

Creating new directories (or folders) is a common task when organizing your files or setting up new projects. In the terminal, you can create directories using the mkdir command, which stands for ‘make directory’.

The basic usage of mkdir is straightforward. Just type mkdir followed by the name of the directory you want to create. For example, to create a directory named myproject, you would use:

mkdir myproject

This will create a new directory named myproject in your current directory. You can verify that the directory was created using the ls command:

ls

If myproject was created successfully, you should see it listed in the output of ls.

You can also create a directory in a different location by specifying a path. For example, to create a directory named myproject in the projects directory, you would use:

mkdir projects/myproject

This assumes that the projects directory already exists. If it doesn’t, mkdir will give an error. However, you can tell mkdir to create any necessary parent directories by using the -p option:

mkdir -p projects/myproject

This will create both projects and myproject if they don’t already exist.

The touch Command

The touch command is a standard command used in UNIX/Linux operating system which is used to create, change and modify timestamps of a file.

Let’s say you want to create a new file named ‘example.txt’. You can do this using the touch command like so:

touch example.txt

If the file ‘example.txt’ does not already exist, the touch command will create a new file with this name. If the file already exists, touch will update the last-modified time of the file.

Removing Files & Folders

The rm and rmdir commands are used to remove files and directories respectively.

The rm command removes specified files. For example, to remove a file named ‘example.txt’, you would use the rm command like this:

rm example.txt

Be careful when using rm, as it deletes files permanently. It’s not like moving a file to the trash bin, it’s more like shredding that file!

The rmdir command removes empty directories. To remove a directory, it must be empty of files and other directories. Here’s how you would remove a directory named ‘example_directory’:

rmdir example_directory

If you want to remove a directory and its contents, you can use the rm command with the -r (or --recursive) flag. This tells rm to remove the directory and its contents recursively. Be very careful when using this command, as it will permanently delete the directory and everything within it:

rm -r example_directory

In summary, touch is used to create or update files, rm is used to remove files and directories, and rmdir is used to remove empty directories.

More Tips and Best Practices

  1. Master the basics: Start with the basic commands like ls, cd, pwd, touch, rm, and mkdir. Once you’re comfortable with these, you can start learning more advanced commands.
  2. Use Tab Completion: This is a handy feature that allows you to auto-complete file and directory names. Simply start typing the name and then press Tab to auto-complete it.
  3. Learn to use the man pages: The man command followed by any other Linux command will display the manual page for that command. This is a great way to learn what a command does and how to use it.
  4. Use the history command: The history command will show you the last commands you’ve used. This can be very helpful if you need to repeat a command or can’t remember a command you used previously.
  5. Learn to use pipes and redirection: Pipes (|) and redirection (>, >>, <) are powerful features that allow you to chain commands together or redirect input and output.

Common Mistakes and How to Avoid Them

  1. Deleting the wrong file: Always double-check the file name before running a rm command. You might also want to use the -i (interactive) option with rm to confirm before deleting.
  2. Using wildcards carelessly: Wildcards like * can be very useful, but they can also be dangerous if used carelessly. For example, rm * will delete all files in the current directory!
  3. Not understanding command options: Before using an option (like -r with rm), make sure you understand what it does. The man pages are a great resource for this.
  4. Overusing sudo: The sudo command gives you superuser privileges, which means you can do things that regular users can't, like deleting system files. Use sudo sparingly and only when necessary.
  5. Not backing up data: Always back up important data. While Linux commands can be powerful, they can also be destructive if used incorrectly.

Conclusion

We've taken quite a journey through the world of Linux commands and the terminal. We started with the basics, learning about commands like ls and pwd, and then moved on to making directories, removing files, and understanding man pages and flags. We've also discussed some common mistakes and best practices to keep in mind when working with the terminal.

Remember, don't be discouraged if you don't remember all the commands or concepts right away. Keep practicing, keep experimenting, and before you know it, you'll be wielding the terminal like a pro.

Additional Resources

For those of you who are eager to continue your journey with Linux commands and the terminal, here are some additional resources that you might find helpful:

  1. The Unix Shell: A great tutorial for beginners from Software Carpentry.
  2. Linux Command Line Basics: A free course from Udacity that covers the basics of the Linux command line.
  3. Advanced Bash-Scripting Guide: For those interested in scripting, this guide is a comprehensive resource.
  4. Explain Shell: A handy tool that explains what each part of a Unix command does.
  5. ManKier: Another great tool for understanding Unix commands. It provides explanations for commands and their options.

The post The Complete Guide to Becoming a Web Developer: Part 6 appeared first on ProdSens.live.

]]>
https://prodsens.live/2023/08/06/the-complete-guide-to-becoming-a-web-developer-part-6/feed/ 0
Improving Your Workflow as a Developer with Bash Aliases https://prodsens.live/2023/08/05/improving-your-workflow-as-a-developer-with-bash-aliases/?utm_source=rss&utm_medium=rss&utm_campaign=improving-your-workflow-as-a-developer-with-bash-aliases https://prodsens.live/2023/08/05/improving-your-workflow-as-a-developer-with-bash-aliases/#respond Sat, 05 Aug 2023 08:25:22 +0000 https://prodsens.live/2023/08/05/improving-your-workflow-as-a-developer-with-bash-aliases/ improving-your-workflow-as-a-developer-with-bash-aliases

As a developer, you most likely spend a significant amount of time working with the command-line interface (CLI).…

The post Improving Your Workflow as a Developer with Bash Aliases appeared first on ProdSens.live.

]]>
improving-your-workflow-as-a-developer-with-bash-aliases

As a developer, you most likely spend a significant amount of time working with the command-line interface (CLI). The command line is a powerful tool that allows you to interact with your operating system and execute various tasks efficiently. However, typing long and repetitive commands can become tedious and time-consuming. Fortunately, Bash aliases can help you streamline your workflow and boost productivity. This article will explore what Bash aliases are and how you can use them to enhance your development process.

Prerequisite

Before you begin, this article requires basic knowledge of the terminal/CLI and bash commands.

What is a Bash Alias?

A bash alias is a user-defined shortcut for frequently used commands. When you create an alias, you assign a custom name to a command or a series of commands. Once defined, you can use the alias instead of typing the entire command. Aliases are specific to your user profile and can be stored in your shell’s configuration file, such as .bashrc or .bash_profile.

For example, the following alias command creates a shortcut for the ls -al command:

alias ls="ls -al"

This shortcut can then be used to list all of the files and directories in a directory. So, instead of writing the longer command ls -al every time you need to list the files in a directory, you can now type ls.

Benefits of Using Bash Aliases

There are several benefits to using Bash aliases:

  1. Increased productivity : By reducing the time spent typing repetitive commands, you can focus more on coding and development tasks.

  2. Customization : Bash aliases are entirely customizable, tailored to your specific needs and preferences.

  3. Error prevention : Since aliases can be designed to avoid complex or risky commands, you can reduce the chances of making mistakes when running important commands.

Creating a Bash Alias

To create a Bash alias, follow these steps:

  1. Open your terminal.

  2. Navigate to your home directory (cd ~) if you’re not already there.

  3. Edit your shell configuration file using a text editor like Nano or VSCode. For example, to edit .bashrc, use nano ~/.bashrc or code ~/.bashrc.

  4. Add your alias definitions to the file. The syntax for creating an alias is: alias shortcut='command'. Replace shortcut with the name of your desired alias and command with the actual command or commands you want to associate with the alias.

  5. Save the file and exit the text editor.

  6. To make your changes take effect, restart your terminal or run the command source ~/.bashrc.

Aliases with Multiple Commands

Using logical operators such as the AND (&&) and OR (||) operators, you can create aliases with multiple commands.

alias shortcut='command1 && command2'

Using the AND (&&) Operator

The double ampersand is a logical AND operator used to execute the second command only if the first command succeeds (i.e., returns an exit status of 0). However, if command1 fails (returns a non-zero exit status), command2 will not be executed. Here’s an example alias in Bash:

alias npmsetup='npm install && npm run dev'

In this example, you’ve created an alias called npmsetup. When you execute npmsetup, it will first install all the packages in the project using the command npm install. If the installation is successful, it will then run the development server using the npm run dev command.

Using Semicolon (;)

In Bash, the semicolon is a simple command separator. When you use it to separate commands, Bash will execute each command sequentially, regardless of whether the previous command succeeded or failed. This means that all commands separated by semicolons will be executed, even if some of them produce errors.

alias shortcut='command1 ; command2 ; command3'

In this case, command1 will be executed first, followed by command2, and then command3, irrespective of whether any of them fail or succeed.

Using the OR (||) Operator.

The double pipe is a logical OR operator used to execute a second command when the first command fails: When you use command1 || command2, Bash will execute command1 first. If command1 fails (returns a non-zero exit status), then Bash will proceed to execute command2. However, if command1 succeeds (returns an exit status of 0), command2 will not be executed. lets have a look at an example of using the || operator:

Imagine you want to create an alias command dev that turns on the development server in a JavaScript/Typescript project, using the || operator you can create the alias as follows:

alias dev='npm run dev || npm run develop'

In this example, you’ve created an alias called dev. When you execute dev, it will first try to run the development server using the command npm run dev. If that command is not found or fails, it will then try the second command npm run develop.

Bash Alias Examples

Lets consider some practical examples of bash alias commands that can help improve your development workflow.

I use the following alias commands to run common git and development commands with just a few keystrokes without having to type the whole command:

alias gm='git commit -m'
alias pull='git pull'
alias push='git push'
alias gs='git status -sb'
alias gc='git checkout'
alias gb='git branch'
alias gline='git log --oneline'
alias gcp='git cherry-pick'
alias add='git add'
alias addall='git add .'
alias dps='docker ps'
alias dcu='docker-compose up'
alias cf='STAGE_BACKEND=true yarn start'
alias dev='npm run dev || npm run develop'
alias clean='npm run clean'

Reference

Conclusion

Bash aliases can help you optimize your workflow as a developer. By creating shortcuts for common commands, you can save time, improve productivity, and make your development experience more enjoyable. So, don’t hesitate to start creating your custom aliases today to improve your productivity on your daily development tasks.

Happy coding!

I’d love to connect with you on Twitter | LinkedIn | GitHub

The post Improving Your Workflow as a Developer with Bash Aliases appeared first on ProdSens.live.

]]>
https://prodsens.live/2023/08/05/improving-your-workflow-as-a-developer-with-bash-aliases/feed/ 0
Setting up ZSH and Oh-my-ZHS with autocomplete plugins https://prodsens.live/2023/02/14/setting-up-zsh-and-oh-my-zhs-with-autocomplete-plugins/?utm_source=rss&utm_medium=rss&utm_campaign=setting-up-zsh-and-oh-my-zhs-with-autocomplete-plugins https://prodsens.live/2023/02/14/setting-up-zsh-and-oh-my-zhs-with-autocomplete-plugins/#respond Tue, 14 Feb 2023 15:03:55 +0000 https://prodsens.live/2023/02/14/setting-up-zsh-and-oh-my-zhs-with-autocomplete-plugins/ setting-up-zsh-and-oh-my-zhs-with-autocomplete-plugins

In this post I’ll provide you with step-by-step tutorial on how to set up oh-my-zsh in your terminal…

The post Setting up ZSH and Oh-my-ZHS with autocomplete plugins appeared first on ProdSens.live.

]]>
setting-up-zsh-and-oh-my-zhs-with-autocomplete-plugins

In this post I’ll provide you with step-by-step tutorial on how to set up oh-my-zsh in your terminal with in my opinion, essential plugins.
First things first:
If you run Linux you can use your packet manager to install all neccesarry packages and jump straight to configuration section.
Instead of apt install use your packet manager commands.

Linux install using packet manager

sudo apt install zsh-autosuggestions zsh-syntax-highlighting zsh zsh-autocomplete

Terminal install using Git and sh

sh -c "$(curl -fsSL https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
  • Install plugins

    git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions

    git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting

    git clone https://github.com/zdharma-continuum/fast-syntax-highlighting.git ${ZSH_CUSTOM:-$HOME/.oh-my-zsh/custom}/plugins/fast-syntax-highlighting

    git clone --depth 1 -- https://github.com/marlonrichert/zsh-autocomplete.git $ZSH_CUSTOM/plugins/zsh-autocomplete

Configuration

  • Enable plugins by adding them to .zshrc.

    • Open .zshrc
    • nano ~/.zshrc
    • Find the line which says plugins=(git).
    • Replace that line with
 plugins=(
  git
  zsh-autosuggestions
  zsh-syntax-highlighting
  fast-syntax-highlighting
  zsh-autocomplete
 )
  • Reload your environment to make changes work!

    • source ~/.zshrc

Optional

  • Enable cutom theme
    • nano ~/.zshrc
    • Find the ZSH_THEME="robbyrussell"
    • Replace with ZSH_THEME="alanpeabody"

You can find my fork of the file on Github Gists

The post Setting up ZSH and Oh-my-ZHS with autocomplete plugins appeared first on ProdSens.live.

]]>
https://prodsens.live/2023/02/14/setting-up-zsh-and-oh-my-zhs-with-autocomplete-plugins/feed/ 0
ZSH on Windows without WSL https://prodsens.live/2022/10/11/zsh-on-windows-without-wsl/?utm_source=rss&utm_medium=rss&utm_campaign=zsh-on-windows-without-wsl https://prodsens.live/2022/10/11/zsh-on-windows-without-wsl/#respond Tue, 11 Oct 2022 21:02:59 +0000 https://prodsens.live/2022/10/11/zsh-on-windows-without-wsl/ zsh-on-windows-without-wsl

Well, WSL it’s a good way to have a Unix environment on Windows, but sadly his performance and…

The post ZSH on Windows without WSL appeared first on ProdSens.live.

]]>
zsh-on-windows-without-wsl

Well, WSL it’s a good way to have a Unix environment on Windows, but sadly his performance and memory consumption leads me to find another alternative… and I found it in a place closer than I expected.

1. Bash

The first step is to download and install git with bash terminal support.

2. ZSH

At least Bash is better than the windows CMD, but ZSH is in another league with his productivity boosts. So we are going to install ZSH over Bash.

Download ZSH

Download the latest MSYS2 zsh package from the MSYS2 package repository. The file will be named something along the lines of zsh-#.#-#-x86_64.pkg.tar.zst

zst files can be decompressed with PeaZip

Install

Extract the contents of the archive (which should include etc and usr folders) into your Git Bash installation directory. This is likely to be under C:Program FilesGit. Merge the contents of the folder if asked (no files should be getting overridden).

Setup

Open the Git Bash terminal and run zsh command, then verify the installed version.

zsh --version
zsh 5.9 (x86_64-pc-msys)

Configure zsh as the default shell by appending the following to your ~/.bashrc file:

if [ -t 1 ]; then
  exec zsh
fi

Windows can mangle some UTF-8 encoded text, causing unexpected characters to be displayed in your terminal. To fix this, add the following to your ~/.bashrc file, ideally, before the code that sets your shell as zsh:

/c/Windows/System32/chcp.com 65001 > /dev/null 2>&1

3. Oh my zsh!

Install

Add superpowers to zsh installing Oh my zsh! running this command.

sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"

Fonts

Download and install manually the Meslo Nerd Fonts to include all glyphs and symbols that Powerlevel10k may need

Theme

There are a lot of themes but my favorite is Powerlevel10k because is easy to set up and use.

git clone https://github.com/romkatv/powerlevel10k.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/themes/powerlevel10k

If it doesn’t trigger automatically, type p10k configure.

Wizard

On the ./zshrc file add this additional configuration

ZSH_THEME="powerlevel10k/powerlevel10k"
POWERLEVEL9K_RIGHT_PROMPT_ELEMENTS=(history)
POWERLEVEL9K_SHORTEN_DIR_LENGTH=1

export LS_COLORS="rs=0:no=00:mi=00:mh=00:ln=01;36:or=01;31:di=01;34:ow=04;01;34:st=34:tw=04;34:pi=01;33:so=01;33:do=01;33:bd=01;33:cd=01;33:su=01;35:sg=01;35:ca=01;35:ex=01;32:"

Plugins

Oh My zsh! have a lot of plugins to use. It’s recommended to explore the options and use what is good for your needs.

I’ve already installed a lot related to software development and other ones to add more functionalities. Running these commands:

git clone https://github.com/zsh-users/zsh-autosuggestions.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-syntax-highlighting

And now edit the ./zshrc file and add it inside the plugins property (don’t use commas as separator)

ZSH_HIGHLIGHT_HIGHLIGHTERS=(main brackets pattern cursor root line)
ZSH_HIGHLIGHT_PATTERNS=('rm -rf *' 'fg=white,bold,bg=red')

plugins=(
    adb
    command-not-found
    deno
    docker
    git
    github
    gitignore
    history-substring-search
    node
    npm
    nvm
    yarn
    volta
    vscode
    sudo
    web-search
    z
    zsh-autosuggestions
    zsh-syntax-highlighting
)

If you are using NVM take care of following this configuration to avoid slowing the zsh start-up

4. Terminals

To use the same terminal inside VSCode and Windows Terminal follow these configurations.

VS Code

Add these properties to the user setttings.json

{ 
    ...
+   "terminal.integrated.fontFamily": "MesloLGS NF",
+   "terminal.integrated.fontSize": 12,
+   "terminal.integrated.shellIntegration.enabled": true,
+   "terminal.integrated.defaultProfile.windows": "Git Bash",
    ...
}

Microsoft Terminal

Add these configurations on the Git Bash terminal.

{
    "profiles": {
        "defaults": {},
        "list": [
+               "font": {
+                   "face": "MesloLGS NF",
+                   "size": 12
+               },
                "guid": "{2ece5bfe-50ed-5f3a-ab87-5cd4baafed2b}",
                "hidden": false,
                "name": "Git Bash",
                "source": "Git",
+               "startingDirectory": "D:\Developer"
            },
        ]
    }
}

Downsides

  • Not as fast as I expected, but much faster than WSL (and also not dealing with his memory and performance issues)
  • Take some time to load the first time (but, less than WSL)
  • Volta on Windows requires additional permissions, maybe you gonna need to come back to NVM
  • Strange behavior while writing inside VS Code terminal
  • Can’t use paths saved on %VARIABLE%, you are going to need to translate it with cygpath $LOCALAPPDATA. To change to a path use something like this $(cygpath $LOCALAPPDATA)/Volta/tools/image/node/

Sources

That’s All Folks!
Happy Coding
🖖

ko-fi

The post ZSH on Windows without WSL appeared first on ProdSens.live.

]]>
https://prodsens.live/2022/10/11/zsh-on-windows-without-wsl/feed/ 0