7 ms·
Enhancements to Shell and Vim Productivity
- nicholassmith 14y ago"A commenter mentioned using Dropbox for synchronization as well, which seems attractive, but I’m not sure how clean that would be on headless Linux servers." Dropbox does work pretty nicely on headless Linux servers, you just have a daemon running constantly with none of the GUI extensions. I use it for keeping some code in check. Nice list of things to try, I don't use vim but I've been putting off doing 3 of them (caps remap, iTerm and zsh).
- robmil 14y agoFor some (entirely irrational, I'm sure) reason, the idea of constant and automatic deployment of my dotfiles across all my boxes gives me the shivers. I like that extra bit of control I get from doing it with a git repo.
- nicholassmith 14y agoSame, which is why I git repo them as well. It's mostly a nice way to keep a few bits of code in check, plus handy for quick private repos without needing all the nice stuff from GitHub/BitBucket.
- pfraze 14y agoCaps remap is my favorite. My pinky is much happier.
- deleted 14y ago[deleted]
- Permit 14y agoI do this as well, but I sometimes question whether or not it was worth the frustration when using a colleagues computer.
- jlgreco 14y agoThere are certain kinds of customizations that I think are backwards compatible in a way. No matter how many custom mappings I make in Vim, when I am using someone else s settings I have never had an issue with not having them. Maybe if that other person also happened to use the colourscheme I like that would be different. For whatever the reason though, capslock/escape remapping is not one of those changes for me. Working on a machine that doesn't have that is absolutely crippling; it takes a great deal of effort to not constantly hit capslock. My solution is to only use my own computers. Mileage may vary. ;)
- pfedor 14y agoAs any book about RSI will tell you, you should not use your pinky finger for pressing Ctrl regardless of whether it's mapped on Caps Lock or on the default key.
- adestefan 14y agoI started doing this when bouncing between a Thinkpad and a regular keyboard. That damn Fn key on the Thinkpads!
- dbbolton 14y agoI'm a full-time Vim user who has never taken to `bindkey -v`. The reason is simple: I'm using insert mode 99% of the time, so using vi keybindings just makes me have to hit an extra key. However, it is useful some of the time. Since viins is pretty useless by default, you can spice it up by setting custom bindings (e.g. copy emacs') and get the best of both worlds. Furthermore, this may be helpful: http://www.bewatermyfriend.org/media/vi-mode.zsh http://www.bewatermyfriend.org/media/vi-mode.zsh
- JulianWasTaken 14y ago`bindkey -v` puts you in insert mode by default (there's a way to make it not do that, but the default is insert first). So there's not really an extra key, you get both benefits :).
- dbbolton 14y agoI meant that you have to hit an extra key to actually make use of the mode's default bindings.
- derwiki 14y ago> inoremap jj <ESC> A mapping I've been using for years. I'm pretty sure between this and Ctrl-c, I never hit escape in Vim anymore.
- jrajav 14y agoI've always used Ctrl-[. It's there in all Vim installs, doesn't conflict with anything else that I know of, and is a quick, no-glance pinky shift for both hands (assuming you remap your Capslock to Control). Edit: Ninja'd by top-level comment!
- wahnfrieden 14y agoIn OSX at least, there's a way you can make Caps Lock behave as Ctrl when used as a modifier key, or Esc when pressed alone. Way better than adding an extra keystroke to every time you want to hit Esc.
- ryane 14y agoDo you happen to know a resource that explains how you do this?
- bti 14y agoThe way I do it is: map caps lock to Ctrl in System Preferences, then download this tool[1]. The setting you are looking for is 'Control_L to Control_L'. When you hold Control it acts as a modifier but if you tap it, it acts as escape. [1] http://pqrs.org/macosx/keyremap4macbook/ http://pqrs.org/macosx/keyremap4macbook/
- 0ren 14y agoMore details can be found in the ctrl/escape section in: http://stevelosh.com/blog/2012/10/a-modern-space-cadet/ http://stevelosh.com/blog/2012/10/a-modern-space-cadet/
- deleted 14y ago
- blux 14y agoWhen you have already remapped Caps-Lock as an additional control, why not just use Ctrl-[ instead of the 'jj' remapping for Escape. It saves a bit of Vim configuration, and also works in Bash vi mode.
- JulianWasTaken 14y agoSame. I'm weary of inoremaps and Ctrl-[ is just really easy.
- emidln 14y agoI just remapped Caps Lock as Escape. I use Escape a lot between tmux with vim modes, bash, and vim itself. I do this in OSX and for the linux console and X11.
- wahnfrieden 14y agoI've also seen setups that somehow let Caps Lock work as Ctrl when used as a modifier key, and Esc when used regularly.
- deleted 14y ago[deleted]
- edanm 14y agoOne small suggestion (I make this every time vim comes up): Don't remap "jj" to escape. Remap "jk" instead. All of the same benefits, plus one more - if you get into the habit of nervously hitting "jk" all the time, as most people do in vim, using "jk" means your cursos stays in place. On the other hand, "jj" means your cursor will move.
- cmatteri 14y agoI was going to suggest mapping both jf and fj to escape so you could mash the two keys at the same time without worrying about order, but jk and kj would work as well
- dguaraglia 14y agoHah, I thought I was the only one doing the stupid "jk" thing.
- Aardwolf 14y agoWhy is this article so Mac oriented? So here's tip 9: Use a nice Linux or similar machine with a pleasant to use clicky keyboard and a mouse which allows text highlight and middle click paste.
- bdunbar 14y agoI've got a pleasant clicky keyboard, a mouse, a linux host (slackware) available in terminal with X11 apps piped over ... and OS X. A long time ago, OS2 was better at running Windows apps than Windows was. The same is true for OS X running Linux ..
- Watabou 14y agoYou know I don't really get this sentiment. And I just think people hate on the Mac because they want to. I never saw the appeal of Linux. Yes, it's free, and I can buy a cheap PC to run it on but why would I do that? My Macbook Pro has the best keyboard I've ever used (the 2008 "pro keyboard", not the chicklet keys Apple uses these days) and the trackpad is better than ALL trackpads out there. Seriously, Apple knows how to make trackpads. And on top of that, OS X is as much Unix as Ubuntu or any other distribution of Linux and I can do whatever work I would have done on Linux on my mac. If I don't have a command line tool, I just use homebrew to install it or build it from source if homebrew doesn't have that formula. And you know what I get including those nice things? The wealth of awesome OS X apps, like Textmate, Keynote, iTerm, Kaleidoscope, QuickSilver/Alfred, XCode, Pixelmator, Time Machine etc that are available. So I ask you, why would I use a Linux machine when OS X is supremely better in almost every way?
- Aardwolf 14y ago1) The article has a title making it seem like it's unix shell tips straight from the unix master, then instead is advising to use certain Mac programs. 2) A trackpad can NEVER replace a regular mouse with scrollwheel and many buttons. Maybe the apple.com website triggers your emotions. But the following website triggers mine: http://www.razerzone.com/gaming-mice http://www.razerzone.com/gaming-mice 3) OS X may be supremely better for you, but not every person is the same, you may be their target audience, other people are not and, gasp, may actually prefer a different design philosophy. 4) Being free or cheap is not usually a reason why one runs Linux on a PC. Can you imagine someone can actually prefer something, independent of cost? 5) Mac OS X has apps. Other OSes also have apps. They all have their selection of awesome apps. Usually one prefers the ones they're used to I guess.
- moonboots 14y agoOn linux caps lock can be mapped to both control and escape, depending on context. https://github.com/alols/xcape https://github.com/alols/xcape
- pfedor 14y agoDo people really not use caps lock? I use it every day, when I need to type more than one upper case character in a row. Like, every time I type NSString, not to mention CLOCKS_PER_SEC.
- ernesth 14y agoCaps Lock is also the most simple way to input Ç, À or É with a french keyboard. Not everyone needs it though.
- martinced 14y agoIt's better than that: several quality keyboards do not even come with a CAPS LOCK key anymore. For example if you're into quality switches, rated for 50 millions keypresses and providing a better tactile feedback than the typical $5 chinese mass-produced keyboard, you may want to shell out $250 to buy an Happy Hacking Pro 2 or a Realforce keyboard using Topre switches (you can have very good Cherry MX based boards for way less than that that said). Some of these keyboards, like the HHKB Pro 2, don't even have Caps Lock. They have Control in place of Caps Lock. So "Do people really not use caps lock?" is not the correct question. The correct question is: "Do programmers who touch-type and who spent time figuring out which keyboard switch they like really not use caps lock?" and then the answers becomes "yeah, most really don't use caps lock because Ctrl is so much more useful and so easier to use when it's located where caps lock typically is. To the point that companies building $$$ keyboard for that market don't even bother selling keyboard with caps lock" : ) "CLOCKS_PER_SEC" should be "CLO" and then auto-complete anyway. Regarding NSString, that's keypress, keyrelease (turning capslock on), 'n' 's' 's', keypress, keyrelease (turning capslock off). Doing it without capslock is keypress (shift), 'n' 's' 's', keyrelease. Which IMHO is faster but YMMV. People touch-typing are alternating Shifts when needed when typing all-caps or typing lowercase and uppercasing the whole word using some vi(m)/emacs magic shortcut anyway ; )
- bdunbar 14y agoI use caps lock, but I use 'ctrl' more often.
- void-star 14y agoI tried iTerm for about a year. After getting fed up watching it lag or crash all the time. I definitely went back to stock Terminal and haven't looked back.
- mtts 14y ago"7. Use vi-mode in Your Shell" Tried this and gave it up. Your shell may be (somewhat) vi compatible but the applications you use mostly are not so you'll have to break out of the vi mindset at all sorts of inopportune moments. That, and modal editing, while perfectly alright for text editing, maps rather lousily to command line operations. You're much better off getting used to some basic Emacs-style key bindings that work consistently across a wide number of applications (including OS X text fields, IIRC).
- kittxkat 14y agoWhat I did, for example, was that I enabled vi-mode in my shell but also re-enabled some emacs-keybindings like CTRL-E and CTRL-A for ending and beginning of a command because I learned them like a lifetime ago when I first got used to the shell without even knowing they were emacs-keybindings. But that way I am also able to hit ESC and do a / for a search, like within vim, which I am much more used to than a search in emacs. I found that way combines the best of both worlds.
- jlgreco 14y agoI use vi-mode in my shell but the end/beginning Vi commands (A,I,0,$,etc) are the only ones I find myself using regularly. I also use c[motion] and d[motion] on occasion, but that is pretty much it. I'm not convinced that powerful editing is necessary for the command line, but familiar shortcuts for beginning/end seem very useful.
- dllthomas 14y agoThere are absolutely times that powerful editing is mandatory at the command line; I am skeptical that there are times when powerful editing at the command line is necessary but pulling the line into your $EDITOR (v in vi-mode, ctrl-x ctrl-e in emacs-mode) is not the best way to deal with it.
- ibotty 14y agobut it's not about powerful editing alone. it's about nice things that are just in your fingertips, say using 'df ' to delete a --long-argument=/a/very/long/path from a command...
- erikcw 14y agoAs a Vim user, I've always been drawn toward using vi keybindings in bash. However, as a Mac user, all of the Cocoa text widgets more or less support emacs keybindings, so having a working knowledge of basic emacs movement commands has been very useful. The emacs bash/readline keybindings also have a really neat trick that the vi bindings don't -- keyboard macros! Ctrl-( to start recording, Ctrl-) to stop, and Ctrl-x to execute.
- nickkthequick 14y agoHow is Ctrl- different from using "q" in vi?
- babarock 14y agoIt's a matter of muscle memory. I used Vim exclusively for several years, and used vi-mode on my shells. Now that I've switched to emacs, my fingers are more comfortable using Ctrl-<key> for commands.
- erikcw 14y agoAt least for me, macros don't work in Bash vi-mode. Perhaps it is only implemented in emacs-mode? Or maybe it is the readline version I have in OSX.
- bdunbar 14y ago1. Remap Your CAPSLOCK Key Another upside to this is that people will gradually stop asking to use your laptop 'for just a minute'.
- jlgreco 14y agoRemapping the arrow keys to switch between Vim windows instead of moving the cursor is a great way to achieve that goal. ;)
- pajju 14y agoecho "set editing-mode vi" >> ~/.inputrc This will turn on vi mode for anything that uses the readline library (there's a good chance your favorite database command line uses it and any other apps that also use the readline library)
- jlgreco 14y agoOne of the issues I have with tmux is that like xterm, but unlike screen, it doesn't reflow text when you resize. I understand doing that probably is not an ideal default, but it would be nice to have the option.
- dllthomas 14y agoI wonder if it makes sense to map capslock to, effectively, ConnectBot's use of the "okay" button on Android - where a single tap is ctrl and a double tap is alt/esc (or vice-versa - it's muscle memory at this point...)