Skip to content

Commit

Permalink
add pseudo-comments
Browse files Browse the repository at this point in the history
  • Loading branch information
wyattscarpenter committed Sep 21, 2024
1 parent eefed30 commit 9f7d3c3
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
8 changes: 8 additions & 0 deletions set-comment-macro.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
REM This batch script sets cmd autorun to use doskey to make // a macro for the REM (remark, ie comment) command. Note that it does this very poorly, because //foo doesn't work as a comment.

reg add "HKCU\Software\Microsoft\Command Processor" /v Autorun /d "doskey //=REM"

REM Alias REM and // to be comments in powershell (perhaps we could call this a pseudo-comment). I don't think side-effects in the commented expressions evaluate, which is nice. Also note that // must be followed by a space. The comment-ness will be terminated by ;, &&, etc, unfortunately.
powershell "echo 'Invoke-Expression \"Function // { }\"' >> $profile"
powershell "echo 'Invoke-Expression \"Function REM { }\"' >> $profile"

3 changes: 0 additions & 3 deletions set-slashes-comment-macro.bat

This file was deleted.

6 changes: 5 additions & 1 deletion utilrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ PS1="\e[0;31m\$?\e[0m⏎$PS1"
cdwp() {
cd `wp "$@"`
}
alias cd-wp=cdwp #fun fact, I guess cd-wp is an invalid function name according to dash shell. It doesn't complain about this alias though (which I think it also technically invalid).
alias cd-wp=cdwp #fun fact, I guess cd-wp is an invalid function name according to dash shell. It doesn't complain about this alias though (which I think is also technically invalid).

mkcd() { #MaKe, and Change to, a Directory. See also https://stackoverflow.com/questions/52071348/how-to-create-folder-and-cd-into-it-with-one-command/52071437#52071437 for more information.
mkdir -p "$1"
Expand All @@ -34,6 +34,10 @@ mkcd() { #MaKe, and Change to, a Directory. See also https://stackoverflow.com/q
# Only a fool would alias REM to # so that REM lines will work on unix. Luckily, I am a fool.
# Please note that this is case-sensitive. I have not aliased all the case variants; out of personal taste (I always write my REM lines with REM in caps, for visual distinctness), and also so that (*checks notes*) the rem command of the remind package will not conflict with this. This alias also does not end in a space, so the command after it will not be alias-expanded. This particular omission is on purpose (in the rest of the file the omissions were not carefully considered), because REM is supposed to be a comment so the less that is done in there the better.
alias REM='#'
# Effectively alias //(it's not valid as an alias name) to be a comment (perhaps we could call this a pseudo-comment). I don't think side-effects in the //-commented expressions evaluate, which is nice. Also note that // must be followed by a space. The comment-ness will be terminated by ;, &&, etc, unfortunately.
//() {
:
}

# This variable is set just because I dislike typing out ~/.bashrc every time I want to look at my bashrc. (The mess of punctuation slows me down.)
# Note that it will not intelligently track your bashrc location or anything like that.
Expand Down

0 comments on commit 9f7d3c3

Please sign in to comment.