Welcome to "TWIL," our weekly digest empowering micro-learning of tech's most engaging complexities. This week, Katie unveils shortcuts for seasoned and aspiring coders alike. Learn the subtle art of tweaking commands with Edit and Re-run Previous Shell Command in Shell, where a simple 'fc' unfolds into a streamlined command-editing workflow. Navigate Git with ease as Katie illustrates how to shorten Git flags intelligently; recognizing when a fragment of a flag is enough to command attention. Finally, perfect your commit game with insights on using Commit Amend with the Same Message in Git, turning omissions and errors into seamless corrections.
Edit and re-run previous shell command
To edit and re-run the previous shell command:
fc
This will open up the previously-run command to edit in Vim; this can be useful for correcting typos in long commands or rearranging flags/args easily.
To run the updated command, just write-quit in Vim and the edited command will be run in the shell upon exit.
- Shell
Git flag shortening
When using git, you only need to type the flag as far as it is ambiguous. For example:
--no-edit
:
--no-e
--force-with-lease
:
--force-w
- Git
Commit amend with same message
If you want to simply amend a commit without changing the message (I personally use this a lot for correcting typos or leftover comments I catch after I've already committed, for example):
git commit --amend --no-edit
Documentation for --amend
:
https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend
Documentation for --no-edit
:
https://git-scm.com/docs/git-commit#Documentation/git-commit.txt---amend
- Git