How to get Base Directory in VScode snippets

What does this snippet do

It reads the current base directory, appends the current name of file

{
  "base-dir": {
    "prefix": "base-dir",
    "body": "/${TM_DIRECTORY/^.+\\/(.*)$/$1/}"
  }
}

You can also set this as a keyboard shortcut. Simply add the following code to key keybindings.json.

{
  "key": "ctrl+k 1",
  "command": "editor.action.insertSnippet",
  "when": "editorTextFocus",
  "args": {
    "name": "base-dir"
  }
}