7 Essential Command Line Tools (2022)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
as i was working through the scripts in my recent ssh and tmux videos i found myself wanting to drop in mentions of my favorite command line tools here and there but those videos were already long enough so here we are seven essential command line tools to improve your productivity all the tools mentioned in this video should be available in the package manager for your platform for mac that's definitely homebrew and probably mac ports too if you're not using a package monitor on mac then check out my homebrew video for more on that i've excluded three important tools from the list in this video zsh starship and tmux because they were all covered in depth in my ssh and team books set up videos just know that when you see my shell in the demos you're seeing zsh and you're seeing starship now onto the main list first up is exa a common command line task is file management and i find myself using the ls command a lot to display the contents of a directory but the default behavior of ls is pretty underwhelming so i like to replace it with exa straight out of the box exa gives a much nicer display and uses a configurable colour scheme to highlight the types of the files shown in the listing so images are shown in this kind of dark purple videos in blue archives in red temporary files in gray and so on and so on i like xs so much that in my shell configuration.shrc i set an alias so that ls actually just runs extra and also since i much prefer long listing rather than gridlisting i add another alias ll to get a nicely formatted full list i also use extra as a replacement for the tree command by aliasing tree to exit dash dash tree i get a nice tree view of my files and i can even combine the tree output with the long output to get a very dense information display in addition to listing directory content i often want to display the contents of a file and the built-in cat command is okay at this but we can do much better with bat bat provides content aware highlighting and line numbers right out of the box which makes browsing code and config files in the shell much easier and with the dash p flag p for plane you can switch off this behavior and get back to a much more cat-like behavior like i did with exer i like to alias bat as cat so years of muscle memory still give me the nice behavior next up we have rip grep which is a great tool for searching your files for specific text or patterns the command for rip grep is rg and simply running it in a directory with the text you want to search for will show you all files containing that text in that directory and the subdirectories here i'm searching for raspberry and i can see all files in my old directory that have that word in but notice on this line that we've only matched raspberry and lowercase exactly as we entered it using rg-i we get case intensive searches and now we're finding all instances of raspberry regardless of the case for more complex searches rip grep supports something called regular expressions or regex if you're not familiar with regex it's like a mini programming language for describing text patterns that tools like rip grep can then match on as an example when i'm editing my videos i keep track of the time stamp markers i want and also the timestamps where i want to put b-roll over my a-roll i can use rip grep with the dash e-flag to search for things that look like timestamps so two numbers followed by a colon followed by two numbers and you don't always want to search all files in a directory structure rip grep allows you to supply what's called a glob basically a pattern for matching against file paths to limit the scope of your search so my org directory has two sub directories tc and rom and if i want to just search for raspberry in the rom directory and only in old files in that directory i can use a glob with dash dash glob of rom slash asterisk.org the asterisk is the variable part of the pattern so this glob matches any org file in the room directory if we try to switch rome to tc in that globe pattern we won't find anything the tc directory has no content of its own the content lives in subdirectories we can extend our glob to search for all log files anywhere under the tc directory using double asterisk so a note here i'm enclosing the globe patterns in either double or single quotes and this is because most shells like zsh that i'm using supports some form of club patterns and without the quotes the shell attempts to process the glob and passes the results to rip grep causing a bunch of confusion another great tool i like to keep around for finding files and searching through text is fuzzy finder or fsdf fuzzy finder is extremely powerful so i can't show everything it can do here but let me show you two use cases that should wet your appetite to find out more firstly you can use fuzzy finder directly at the command line to search for a file when you don't quite know the name so i'm in a directory containing the source code for the techcraft website i know there's a file in here somewhere for an ipad productivity video that i did with fzf i can just type ipad productivity and the list of possible files is immediately narrowed down the more specific my search term the more the result set is narrowed down but notice i'm not actually typing anything that closely resembles the actual file names that's where the fuzzy in fuzzy finder comes in these are fuzzy matches rough approximations based on what you might want and not what you actually typed in where i use s3f the most is in searching my command history so in the shell control r allows you to search your history and with sdf installed you get fuzzy matching on the history so just typing in ex shows up all of the x commands we saw earlier and if i add tree to my search we get just the extra tree commands and enter brings that command to the shell prompt and then enter runs it so normally you move out the file system using cd the change directory command and this is a perfectly fine command but i like to replace cd with zed oxide or xoxide which provides a richer feature set so i'm in the home directory here and i'm going to switch to the directory where my scripts are stored and then switch to the source code for the techcraft website i'm using zed which is the command name for zed oxide in place of cd the first time you visit a directory with zed oxide it remembers the directory path and you can switch to it using just a portion of the path so to switch back to my content directory i can run zed cont and i'm back and running zed tech takes me back to the source code directory it is possible to have name clashes and zed oxide handles this quite nicely so let's say i create a new directory called technology and visit it with zed oxide now zed tech has two possible matches each time i run it it will cycle to the next match and i can also type zed tech then a space and press tab to bring up all the possible matches and you might notice here that zed oxide is using f f for the menu i commonly find myself switching back and forth between two directories and xoxide has a shortcut for that it's z space dash which takes you back to the directory you were last in since xerox is a complete replacement for cd i also like to alias cd to zed and then i also earlier said zed to be zed space dash to make the toggling easier so next up we have enter which is amazing utility with enter you can watch files and when they change you can execute commands this is really useful if you're working on coding and especially if you're learning to code i think this is a very useful command so let me show you what i mean here i have two panes open and in the right pane i've got my editor in the left pane i've got just an empty shell i want to say with enter whenever the source code changes please run the source code so let's use enter to do that and then next up in my editor i'm going to keep changing the code and every time i change and save the file you can see the enter is rerunning it so i can quickly see the output from my code as i change it so i've saved the best for last midnight commander or mc so mc is a dual pane file manager that's been around since like 1994 and he's still in active development mc's a huge program with a ton of features but let me show you some of the basics that i think will pique your interest so first up along the bottom here we have commands with numbers these are for the function keys on your computer so f5 is copy f6 is rename and f7 is maked so on and so on and we have two panes both showing the contents of a directory and currently they're showing the same directory which is my home directory and i can switch between the panes with tab i can move up and down with the arrow keys or with control p control n for previous and next and if you're not using these shortcuts they're worth learning they have significantly less hand movement than the arrow keys i can also search for something in this directory with opt s so i'll search for temp to go to my temp directory and then hitting enter we change into that directory but only in this panel so a few unused directories in here that i can clean up using f8 and now i want to start creating some new directory so just copying some files around f7 allows me to make a new directory and i want to copy the contents of the extra demo directory into this new directory this is super easy in mc so first off i'll put the right pane into the same directory as the left pane using opt i to synchronize the two panes and then come into the new directory with enter now i'll tab over to the right pane move to the exit demo directory and hit f5 to copy and then ok and now we have a copy of our folder in our brand new directory mc does take a little while to learn but it's worth the investment i've been using it regularly since around 2007 and in that time loads of software has come and gone but mc remains and delivers real benefits every day there's so much more i can show you about midnight commander so if you are interested in seeing a full video then do let me know in the comments below so that's seven essential command line tools that i use pretty much every day of every week and i hope you'll find some of these tools a worthwhile addition to your workflow and i hope you found this video useful if so please hit like please hit subscribe and hit the bell as well so you don't miss out on any future content thanks for watching
Info
Channel: Tech Craft
Views: 198,833
Rating: undefined out of 5
Keywords: essential command line tools, command line basics, linux terminal, command line tutorial, raspberry pi command line tutorial, raspberry pi command line, linux tutorial 2022, command line tools, raspberry pi command line only, linux terminal emulators, ipad ssh raspberry pi
Id: 2OHrTQVlRMg
Channel Id: undefined
Length: 9min 12sec (552 seconds)
Published: Sun May 08 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.