DEV Community

Discussion on: OhSnap! Handy Terminal & Git Commands

Collapse
 
moopet profile image
Ben Sinclair

Couple of tips:

cmd + k is going to be specific to MacOS. ctrl + l will work on pretty much any terminal emulator and is also often bound to things like "redraw" in apps as well.

cd ~ will take you to your home directory, but also so will cd on its own.

Opening the current directory in apps, like with code . and open . is the same as passing the complete current path. open is a Mac-specific (in this case) program which dispatches the path parameter to whatever application is associated with "folder" (again, in this case). On Linux you'd do something like xdg-open if you have a GUI, or even something else depending on your configuration. On Windows I suspect you're SOL.
This means if you have something associated with .js files in your GUI (e.g. Finder) then open foo.js will launch that application, regardless of what it is. In that case, open is a tiny bit easier because you can share code using it with others and it'll work even if they use something else like Sublime.

I have a whole rant about using touch to create files.

git diff
To leave this view hit Q on the keyboard

I'm guessing you have less as your pager for git diffs. It doesn't have to be that way though, and even if you do there's a good chance it's not called if there's nothing to diff!

Getting unstuck from hard-to-exit terminal screens

What do you mean by this? What terminal screens are getting stuck? The only time I know ZZ as a shortcut it's an alternative way to save and exit Vim.

Collapse
 
gedalyakrycer profile image
Gedalya Krycer

Thanks for leaving feedback and additional explanations. Regarding your question at the end, I do believe the screen was a VIM editor. It sometimes comes up when I am working with git.

Collapse
 
moopet profile image
Ben Sinclair

Gotcha.

If you're using Vim to edit git commit messages and don't want to, I think there's a git config setting. Failing that, I imagine setting something like;

export EDITOR=$(command -v code)
Enter fullscreen mode Exit fullscreen mode

in your shell config would let you use VS Code instead (or whatever you want)