I’m recently enhancing the $\rm \LaTeX$ code for inline limits. For the reason of doing so, you may refer to the external link of my recent linklog Inline Limit Rendering.
In the previous post in this series written over one year ago, I have included a code block which enables deferred MathJax loading. However, I manually added this chuck of code in the HTML file generated by kramdown, which created the problem described in the next subsection A problem with Vim’s folding arised.
Firstly, save the code for loading MathJax in the previous
post in this series in a separate file ~/script.html
. Then
use the following commands within Vim in order to avoid leaving the
current buffer and to improve efficiency.
9,$w! ~/temp.mkd
!kramdown ~/temp.mkd > ~/temp.html
!cat ~/{temp,script}.html > ~/test.html
The digit 9
in the first command isn’t exact. Change it to any
line number that separates the yaml front matter from the
post content.
A year ago, I was using msysgit on M$ Win* 7. Its support for Unicode characters isn’t so good, and I can’t write a text file with accents like “café” in the Vim editor that shipped with msysgit. As a result, I needed GVim for editing my $\rm \LaTeX$ documents.
Unluckily, unlike Linux, the GVim can never have forward control. Therefore, I needed to switch windows between GVim and Git Bash.
More importantly, if I want to apply the Linux skills and the tools on M$ Win*, I need portable programs excutable on a USB unless I carry my laptop.
Luckily, the bash shell in Git for Windows has improved a lot. The accents are well supported. Then, I have switched from GVim to the embedded Vim in Git for Windows. Luckily, the setup of Vundle was smooth. Most of the installed plugins work fine in terminal Vim.
In the post Git Portable Home Path, a BAT file is included so
that the home folder and the HOMEDRIVE
environment are automatically
set. Since the same Git repository can be shared among multiple
devices, such as my Linux desktop, my M$ Win* 7 laptop, and my USB
stick, a bare repository is needed for efficient pulling and pushing
of Git commits. Since I work outside home, I place a bare Git repo in
my USB stick. However, for each local Git repository stored in the
USB stick (under ~/local_repo
, a.k.a.
$HOMEDRIVE/PortableGit/home/owner/local_repo
), I need to run the
following command for each time I use Git Bash.
After making some changes on a $\rm \TeX$ file, I compiled the file using Mik$\rm \TeX$ Portable.
$HOMEDRIVE/MikTeXPortable/
.miktex-portable.cmd
.$HOMEDRIVE/PortableGit/home/owner/local_repo
.pdflatex file.tex
.This sounds really slow. The goal is to find a more efficient $\rm \LaTeX$ editing workflow.
That’s not the end. Another bad news came from eu1lmr.fd
. I’ve
got error similar to fengbaobao6’s. The compilation was
stuck at ...\tex\latex\euenc\eu1lmr.fd
. Then an error was shown:
“Fontconfig error: Cannot load config file”.
~/.bashrc
if it doesn’t exist.Searching the error text, I found kounoupis’s answer on
Ask Ubuntu. Even though the export
command didn’t
work for me, I still found his answer informative.
Finally, reading miktex-portable.cmd
, I gave up on investigating the
problem, and added the last line of this file into BASHRC since I have
other important things to do.
1
2
3
@echo off
cd /d %~dp0
miktex\bin\miktex-taskbar-icon.exe
To include Mik$\rm \TeX$ into PATH
, I first extracted $HOMEDRIVE
in the form /f
instead of F:/
. If not, Mik$\rm \TeX$ won’t
work.
Here’s my BASHRC for Git Bash.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
stty -ixon
cd ~
HOMEDRIVE=$(perl -e '($var) = $ENV{HOMEDRIVE} =~ /([A-Z]):/; print "/".lc($1)')
if [ $(perl -e '($var) = $ENV{PATH} !~ /tex/i; print STDOUT $var') ]
then
echo "No LaTeX found! Added $HOMEDRIVE/MikTeXPortable/miktex/bin
to path."
PATH=$PATH:$HOMEDRIVE/MikTeXPortable/miktex/bin
echo "IMPORTANT: Close MikTeX Taskbar icon before exit."
echo "Otherwise this shell WON'T close."
miktex-taskbar-icon
fi
loc_repo=(
'resume2015'
)
for f in ${loc_repo[@]}; do
cd $f
git remote set-url origin $HOMEDRIVE/$f.git
cd -
done
If the setup is correct, then \ll
in $\rm \LaTeX$-Suite should
automatically trigger the $\rm \LaTeX$ compilation. I give up on
finding ways to open a viewer with \lv
since I can use the keyboard
to switch to a web browser to see the compiled PDF file without
installing another PDF viewer in my USB stick.
I’ve learnt some Perl and bash after writing this BASHRC.
$ENV{HOMEDRIVE}
for extracting the environment variable
HOMEDRIVE
./(regex_pat)/;
for extracting matching string to capture
groups $1
, $2
… (The ()
around regex_pat
is
crucial.).
for string concatenation.lc()
for converting a string to lowercase.The solution for the problem posed in the title is pretty simple. For instance, I want to find all Git commits whose commit message contains “HTTPS”.1
$ git log -2 --grep="HTTPS"
commit 7400582e268f4a5b776269cf0cc08c04886a4769
Author: Vincent Tam <fake@live.hk>
Date: Sun Mar 20 20:19:47 2016 +0800
Updated my Rakefile with HTTPS
commit b6f4f1fc872affc1107b330042d7b43b45e60595
Author: Vincent Tam <fake@live.hk>
Date: Mon Feb 8 00:45:02 2016 +0800
A new article about Flair, Octopress and HTTPS
However, I think that the output isn’t compact enough. I would like to display the following information.
<short SHA1> <commit time> <commit message title>
$ git log -2 --grep="HTTPS" --pretty="%h %cd %s"
7400582 Sun Mar 20 20:19:47 2016 +0800 Updated my Rakefile with HTTPS
b6f4f1f Mon Feb 8 00:45:02 2016 +0800 A new article about Flair, Octopress and HTTPS
%h
: short SHA1%H
: full SHA1%an
: author name%cd
: commit date%s
: subject%b
: bodyAdding a backslash before each %
in
:r !git log -2 --grep="HTTPS" --pretty="\%h \%cd \%s"
is tedious and prone to errors.
A more convenient way
:exec escape('r !git log -2 --grep="HTTPS" --pretty="%h %cd %s"', '%')
To avoid junk mail, I replaced the first four letters of my email
address with fake
. ↩
I often included Unicode characters in my commit messages, such as
“Committed in a café”. Since I couldn’t input the character ‘é’
inside the Vim editor shipped with msysgit, and the curl
utility
didn’t get along well with my GVim Portable
I decided to upgrade it.
Then I set up things after the installation of Git for Windows so that it works well with Vundle now.1 After that, I thought that it would be great if I can set it up on a USB stick so that the Vim editor with the powerful plugins can be executed on every M$ Win* 7 machine.
The first Google search result for “git portable” is the webpage for Git for Windows downloads. To get it installed on a USB device, don’t click “Save file” for the dialog box that popped up upon the page is loaded. Choose the “thumbdrive edition”.
Each time I opened the Vim editor from Portable Git Bash from the USB,
a new .viminfo
file was created in the home folder of current user
in the C drive. (e.g. C:\Users\Foo\.viminfo
) Therefore, it could
be deduced that VIM installed (under /usr/share/vim/vim74
) in the
USB couldn’t load the configurations from .vimrc
stored on the
same USB. What an irony!
How can one build a truly portable Vim in the USB stick?
Searching “git portable home path” on Google, I found
an article about setting $HOME
and SSL keys for GitHub.
However, it was written several years ago. In the current version
of Git for Windows, git-bash.bat
doesn’t even exist.
Another search result was a Stack Overflow question. I
tried copying dgw’s wrapper into git-bash-portable.bat
. I
adapted it to my installed copy of Git Portable by changing the
extension name at the last line from bat
to exe
. Unluckily, it
took a long time to load the Portable Git Bash on clicking the batch
file.
I found Jason Cemra’s comment on issue #320 of Git for Windows on GitHub extremely useful.
1
2
3
4
5
6
7
rem Setup environment (replace 'user' with your desired username)
set HOMEDRIVE=%~d0
set HOME=home/owner
set USERPROFILE=%HOME%
rem Launch the git bash
start git-bash.exe
I borrow the line set HOMEDRIVE=%~d0
from dgw since the drive
letter of the USB can change. This facilitates the process of
adjusting the path of the origin
when it comes to pushing a non-bare
Git repository in the USB device to a bare one in the same device.
(If the Win* machine doesn’t have Git and Vim installed, I use the
ones in my USB stick. Otherwise, I use the installed versions of
those softwares.)
Since the shell of a Vim session invoked by Git Bash is automatically
set to /usr/bin/bash
, it is expected that
Zaadi’s VIMRC configuration for automatic installation of
Vundle works. Though I’m using the version written two years ago,
it still functions well.
To write in $\rm \LaTeX$ on every Win* 7 device, I also copied the Mik$\rm \TeX$ Portable from my laptop to my USB stick.
I practised my sed
skills by using sed '2 i set HOMEDRIVE=%~d0'
to
insert contents before the second line.
See the newest series Git for Windows, Curl, Gist.vim with Vundle for details. ↩
In the third post of this series, I ran the editor command
:!git config --list
inside GVim Portable, but I got a fatal error. I found out how to get Gist.vim work without solving this problem.
How to avoid this fatal error?
C:\Windows\system32\cmd.exe /c (git config --global --list)
fatal: unable to read config file 'C:\Temp\PortableApps\gVimPortable\Data\settin
gs/.gitconfig': No such file or directory
shell returned 128
Hit any key to close this window...
I forgot this article about programming that I’d read several
weeks ago. I should have pay more attention of the error message
itself, rather than the Google search results of this message. Hence,
creating a symbolic link for C:\Users\foo\.gitignore
to the
path/to/Data/settings
folder.
While writing this post, I re-read
Rake Aborted Due to a Vim Swap File so as to find the URL of
the article about programming. I discovered a broken link in the
GitHub page for Octopress issue #600. From the list of
branches in the homepage for this GitHub project, I found site-2.1
,
on which commit 2399008 was located. Therefore, I made commit
68b0adb in the repository for this blog.