Great Auto Mechanic Jobs for Veterans

One of the perks of many military jobs is getting to work with your hands, which is partly why auto mechanic jobs are great for veterans! Many veterans have received technical school and On The Job…


独家优惠奖金 100% 高达 1 BTC + 180 免费旋转

Zshell path modifiers

One common use is to have a path variable and you want to extract the directory name or the extension. You could use commands for this like dirname or basename, but there is a better way than starting a process. There are built-in modifiers. You'll find many examples on the internet which remove something before or after a certain character, but there are better modifiers for this.

Let’s put a path in a variable:

There are 2 ways of splitting a path. The first is head/tail, which splits at the last slash.

The second way is root/extension, which splits at the last dot.

If you want to get only the name of the file without the extension, you can combine tail and root.

There is a lot more to this but if you use them in a string, it is safer to use curly brackets around the variable.

Now another usefull one which gives you the absolute path of the variable.

Note that the paths we make absolute do not have to exist. The modifier just outputs what it would be based on the current directory. And you can use :A instead if you want to resolve symbolic links.

Now the :c modifier outputs the absolute path of command name, using the PATH variable, like what the which command would do.

If you put it in backets, you can use these on regular arguments, even when globbing. This command for example prints all the C filenames (without extension) nested in the src directory.

I know the title of this article refers to “path” modifiers but they don’t have to be used on paths as long as they do what you want. And equally, some modifiers were not created especially for paths, but can be used on them anyway. Here are a few.

Another useful modifier that could be used on path or anything else is the :s modifier. It is the typical substitute that you find in grep and in many other softwares. Here we copy all text files into another one with the markdown extension.

Like many substitution tool, it works only one time. If you want to substitute multiple times, use :gs instead.

Also like many substitution tools, you can use any character for the delimiter. This is handy when you want to replace a slash because otherwise you would have to escape it.

You can quote text with :q and unquote it with :Q.

You can obviously make a variable all lowercase or all uppercase.

There is also a way to capitalize words. I won’t go into details explaining why it looks different, but here is how you do this:

Add a comment

Related posts:

How to connect a wallet

JustSwap is a platform that provides you with the ability to convert Cherry Token to other tokens and vice versa. Get started on JustSwap with our step by step tutorial! 3. Enter the password and log…

Data Analytics in a School Management Software

Data analytics is the science of analyzing raw data to make conclusions. Any data can be submitted to data analytics techniques to gain insight on how to improve things. Data analytics techniques can…

Pickup truck crashes into canal in Phatthalung killing two

The driver of a pickup, along with his passenger friend, were killed and two women injured early today. The pickup careered off the road, hit a bridge, and dropped into a canal in Phatthalung’s Kong…