File tree 2 files changed +28
-1
lines changed
2 files changed +28
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://crafty-builder-6996.ck.page/e169c61186 ) .
12
12
13
- _ 1595 TILs and counting..._
13
+ _ 1596 TILs and counting..._
14
14
15
15
See some of the other learning resources I work on:
16
16
- [ Ruby Operator Lookup] ( https://www.visualmode.dev/ruby-operators )
@@ -1532,6 +1532,7 @@ See some of the other learning resources I work on:
1532
1532
- [ Find Newer Files] ( unix/find-newer-files.md )
1533
1533
- [ Find Occurrences Of Multiple Values With Ripgrep] ( unix/find-occurrences-of-multiple-values-with-ripgrep.md )
1534
1534
- [ Find Top-Level Directories Matching A Pattern] ( unix/find-top-level-directories-matching-a-pattern.md )
1535
+ - [ Fix Previous Command With fc] ( unix/fix-previous-command-with-fc.md )
1535
1536
- [ Fix Shim Path After asdf Upgrade] ( unix/fix-shim-path-after-asdf-upgrade.md )
1536
1537
- [ Fix Unlinked Node Binaries With asdf] ( unix/fix-unlinked-node-binaries-with-asdf.md )
1537
1538
- [ Forward Multiple Ports Over SSH] ( unix/forward-multiple-ports-over-ssh.md )
Original file line number Diff line number Diff line change
1
+ # Fix Previous Command With fc
2
+
3
+ The ` fc ` command is a Bash and ZSH built-in command that allows you to interact
4
+ with the history of commands issued in the shell. The most straightforward use
5
+ case I know of for using this command is to fix or edit some aspect of the
6
+ previous run command.
7
+
8
+ When ` fc ` is executed with no arguments or flags, it will grab the latest entry
9
+ to the command history and load it into your default editor. For me, that is
10
+ Vim.
11
+
12
+ I can make edits in that Vim session like I'd do in any other Vim session. When
13
+ I write and quit (` :wq ` ) the file, the updated command will be executed. This
14
+ is useful if, say, I've made a typo in the previous command and would prefer
15
+ the ergonomics of my default editor to fix it. Or let's say I have a really
16
+ long command with many flags and long file path arguments. It would be much
17
+ easier and quicker to edit those paths from my editor than from the terminal
18
+ prompt.
19
+
20
+ If I've opened my editor (Vim) with ` fc ` and I decide I don't want to execute
21
+ the command after all, I can _ compiler quit_ Vim (exit with an error code)
22
+ using ` :cq ` . The command will not be executed in this case.
23
+
24
+ See ` man zshbuiltins ` for more details about this command and all of its flags.
25
+
26
+ [ source] ( https://www.computerhope.com/unix/uhistory.htm )
You can’t perform that action at this time.
0 commit comments