sublimehq / Packages

Syntax highlighting files shipped with Sublime Text and Sublime Merge
https://sublimetext.com
Other
2.95k stars 586 forks source link

[Bash] Add support for history commands #2415

Open michaelblyons opened 4 years ago

michaelblyons commented 4 years ago
!!
!cmd
!?part of cmd
!?part ?with end trigger
sudo !! # This might depend on #1191
^ehco^echo

History commands are typically disabled in Bash scripts, but text highlighted by the syntax can be non-script. E.g. some Markdown showing sample terminal input.

Look for the packages you have symlinked...

``` sh
ls -l ~/Library/Application\ Support/Sublime\ Text/Packages

...then open one of them

^ls^subl^/Python
deathaxe commented 4 years ago

What exactly do you expect to be highlighted how? The ! is scoped as history already (on my local patchset).

grafik

michaelblyons commented 4 years ago
!! # Good
echo !! # Okay as-is. We could mark `!!` like above, though.

!cmd # Pretty good
echo !cmd # Okay as-is. We could mark `!cmd` like above, though.

!?part of cmd
#^ punctuation.definition.history
# ^^^^^^^^^^^ variable.function? string?
# This is actually a string that will run a function, not the function itself,
#   but "feels" like a function in terms of use.
# I usually do `!?cher` to re-run the last `git cherry-pick`, since
#   `!git` will run a more recent Git command.

echo !?foo
#    ^^^^^ This starts getting weird

echo "!?foo"
#     ^^^^^^ And more weird. The closing `"` is part of the history command

!?part ?with end trigger
#^ punctuation.definition.history
# ^^^^^ variable.function? string?
#      ^ punctuation.definition.history

echo "!?foo?"
#     ^^^^^^ The second `?` fixes the inclusion of `"` in the history command

^ehco^echo
# This one is weird. In a way, the whole thing is a function, but the `^` are
#   also punctuation, and the internal text are strings.

# At least this type only appears to be valid as the first character.

^ehco^echo -e^
# This is like a combination of the two above.