zsh
Functions
Default arguments
Example of a function with default arguments in zsh
function e() {
if [ "$1" != "" ]
then
subl $1
else
subl .
fi
}
File name without the extension
If you want the full path without the extension:
$ myfile=/path/to/story.txt
$ echo ${myfile:r}
/path/to/story
$ myfile=story.txt
$ echo ${myfile:r}
story
If you want just the file name minus the path:
$ myfile=/path/to/story.txt
$ echo ${myfile:t}
story.txt
Check this out you can combine those two symbols!
$ myfile=/path/to/story.txt
$ echo ${myfile:t:r}
story