8 ms·
Linux Terminal Goods
- diegopacheco 7y agoPart 2 https://news.ycombinator.com/item?id=21119949 https://news.ycombinator.com/item?id=21119949
- profunctor 7y agoDiego I think you're using the word asteroids where you mean the word steroids.
- Mic92 7y agoWould be cool though, if somebody would use vim on asteroids.
- dsego 7y agoLooks like a pun.
- jvanderbot 7y ago"On asteroids" is definitely my new favorite phrase.
- ddalex 7y agoI prefer my terminals dumb and without much color, as the UNIX gods intended them to be. This being said, I'm in love with `fzf`, my workflow improved markedly after scripting (on mac) `ggvi() { git grep "$@" | fzf | sed \"s/:/ +/\" | cut -d \":\" -f 1 | gxargs -r -o vim }`
- mkesper 7y agoYou can also combine it with ripgrep. Much faster than git grep.
- ddalex 7y agoI actually time-tested git grep vs ripgrep, and I'm not seeing meaningful differences on my repos. ripgrep smokes regular grep but for some reason git grep is just as fast as ripgrep
- usr1106 7y agogit grep is parallel, too.
- burntsushi 7y agoBecause benchmarking these tools is difficult to do correctly, and is heavily workflow dependent. If your search space is small, them it doesn't really matter what tool you use for example, they are all probably going to be pretty quick. I wrote more about this here: https://lobste.rs/s/0kaozs/don_t_underestimate_grep_based_code#c_vddxv7 https://lobste.rs/s/0kaozs/don_t_underestimate_grep_based_co...
- vectorEQ 7y agohave to agree that colours often disctract more than are of use. they stop you critically reading imo. but i guess that's also a matter of taste or something like that.
- wiz21c 7y agoI've just skimmed around it as someone who repeatedly need that kind of book to achieve little things in bash. I understand bash is the basis of so many things, that its importance is just enormous. But at the same time, I'm appalled by its syntax, idioms, etc. It's barely readable for the casual reader that I am. I wonder why nobody tries to provide a meaningful alternative. I've seen some (in python for example) but I'm kind of surprised nobody puts more money in such an effort. For example, the "trim string" function described at the beginning of the book is horrible (although probably very clever). Why not simply provide a built in function ? That would make code so much cleaner... I ask the question honestly, it's not a rant :-)
- orev 7y agoShells are made for people to interact with, not for programming. They happen to also be useful for programming, so many things have been added on over time to support that. Shell scripting is also the least painful way to call many external programs and glue them together into something useful. Calling external programs from “real” programming languages is far more painful. If you need a real programming language, as you mentioned, use something designed for that.
- pjc50 7y agoGenerally if you're trying to do something that feels like a "program" in shell script, rather than loosely gluing existing tools together, the threshold for moving it into Perl or Python should be low. Even things like trying to get the quoting right for lists of files some of which may have spaces in their names is fiddly enough to drive people to writing a "proper" program. (or was this comment intended for https://news.ycombinator.com/item?id=21013150 https://news.ycombinator.com/item?id=21013150 )
- robohoe 7y agoThe moment I have to use arrays in bash, I open up a python interpreter. Syntax makes far more sense than in bash.
- 7y ago
- RadiantSecurity 7y agoI spend loads of time in a shell. One day I'll push my full dotfiles publicly, but until then here's a few snippets I've found super handy. I'd advise against using them verbatim but there's a few things in there that took some time to figure out. Beware they can be somewhat buggy / break things though. Highlights include: - Bind C-c/C-v to Copy/Paste, bind C-g to sigterm (Note: Breaks docker interactive unless you mount bashrc into /etc/bashrc or similar!) - Autorun tmux on SSH session - Syntax/colour highlighting in zsh interactive, I think there's some diff/less/man magic in there too! - Log all shell activity to .shell_logs (Be _super_ careful with this one, breaking it could prevent you opening an interactive shell - Useful grep defaults, particularly relevant when using .shell_logs Bashrc: https://gist.github.com/YoloClin/f4c82a6e693000a2da20e8029a49656c https://gist.github.com/YoloClin/f4c82a6e693000a2da20e8029a4... Zshrc: https://gist.github.com/YoloClin/ffd82f441d292ccc5f25c62a80c78ad0 https://gist.github.com/YoloClin/ffd82f441d292ccc5f25c62a80c... One thing I've lost love for is Powerline9k - Right-aligned data breaks copy/paste functionality, and patching fonts to get UI-arrows is fiddly for little functional value. If I ever need to fiddle with that stuff again, I'll configure a regular theme to do similar and go without the UI-arrow breaks. I was considering hiding history-relevant log data (such as current system time) to behind a carriage return, something like PS1="$(date)\r$PS1". I'm interested in hearing others' cool, non-standard hacks!
- archi42 7y agoInspired by a colleague, I wrote this (for bash): https://gist.github.com/archi/2a2331401842c0548fa8de0f69796f58 https://gist.github.com/archi/2a2331401842c0548fa8de0f69796f... > up 4 go up 4 folders (=> "cd .." 4 times). > up goes up one folder, and you can repeat pressing ENTER to go up one more. Press anything else to drop back to the shell. Could probably be "better" (e.g. no subshells), but works well for me.
- RadiantSecurity 7y agoThats cool! I'm not sure where it comes from, but I get similar behavior in zsh with 'cd ....' - similar doesn't happen in bash though. I mapped 'cd' to 'c' in my bashrc, but while doing it I also mapped 'c' to execute 'ls' as the latter was basically muscle memory whenever I was using cd. The .bashrc function looks like this: c() { builtin cd "$@" && ls; }
- raveenb 7y agothis is super awesome! love it, thanks for sharing spacevim is exactly what I have been looking for
- CiTyBear 7y agoOther stuff with asteroids: * RipGrep: Replace Grep and it is blazing fast * exa: Replace ls with many more options
- vectorEQ 7y agosome vim enthousiast here scalded me for sending him spacevim linkand told me to use neovim. i don't use vim so i wouldn't know, and vim people seem easily offended :D. anyhow, just thought i'd not his input.
- toyg 7y ago“Hey you like Jehova, right? I’ve been told this Jesus guy is pretty cool, I wouldn’t know myself to be honest but maybe you’d like him?” <stones thrown in the opposite direction>
- packetlost 7y agoSpacevim actually has some original features (kind of ripped off from emacs) that I really like, and can't find a way to get without using Spacevim. There's nothing wrong with using it, but most vim users like to start from scratch and build their own experience to meet their specific needs. Starting with something like Spacevim is 100% ok if you've never used vim before, but most people end up moving onto the more 'custom' experience eventually anyway.
- seamyb88 7y agoI immediately thought "yea I'm gonna keep using neovim" when I read about spacevim.
- xvilka 7y agoJust one link: https://terminalsare.sexy https://terminalsare.sexy
- CoolGuySteve 7y agoRegular vim has tabs and you can bind any key you want to switching them (I use F2/F3). The default is :next and :prev or gt/gT. I’ve been using the feature for years now. You can also open a list of files in separate tabs with the -p argument. So “vim -p CppFile.*” will open the .h and .cpp in separate tabs for example. You can then Y/p between the two buffers. It’s so useful that I always “alias vi=vim -p” in my .profile.
- leggomylibro 7y agoIs the '-p' necessary? I like to open files in windows with e.g. "vim -O file1 file2", and I've noticed that if I accidentally omit the '-o' or '-O', it opens each file in a tab. Or at least, it opens each file in individual pages that you navigate between with ':next' / ':prev'.
- jolmg 7y agoThe -p gives you a tab for every file opened. If you don't provide it, it still opens them and you get a buffer for each one, but it doesn't open any tabs. If you still get tabs even if you don't provide it, maybe you have a vim plugin that's doing that.
- lillesvin 7y agoMaybe I'm completely missing the point of `bat` but I usually just use `view` (vim/neovim in readonly mode) if I want to read files with syntax highlighting, GitGutter, line numbers, etc.
- C0d3r 7y agoBat works the same way as ls when it's being piped. But it has better default features than cat, the syntax, numbers and the pager. if the file doesn't fit the screen, it becomes paged, so you don't have to do the whole: `cat file.txt` (too big), `view file.txt`
- awake 7y agoNot sure if view lets you do this but bat will switch off highlighting if you are piping output `bat file.txt | grep ...`. This makes it easy to make an alias cat=bat and have everything work. Also you can make bat display output with `less` and then line numbers can be toggled, not sure about gitgutter.
- sharkdp 7y ago(author of bat here) Exactly. Drop-in compatibility with 'cat' is one of the goals of bat (see https://github.com/sharkdp/bat#project-goals-and-alternatives https://github.com/sharkdp/bat#project-goals-and-alternative... and a list of alternatives here: https://github.com/sharkdp/bat/blob/master/doc/alternatives.md https://github.com/sharkdp/bat/blob/master/doc/alternatives....). Another thing that I use frequently is previewing a whole set of files in a single (pager) output. Something like bat src/*.cpp This also allows you to easily search across a whole set of open files.
- OskarS 7y agoAwesome work. I've been a happy user of bat for a few months now, I've almost totally trained my brain away from typing cat.
- OskarS 7y agoIt's a similar idea to that, but it's more lightweight and much more of a "drop-in replacement" for both cat and less. For instance, when using it as a replacement for "less", it will use terminal colors correctly (i.e. "ls --color | bat" works like you'd want), it will have the same keybindings as less (i.e. b/f for page back/forward, / for search, q for quit, ...), it wont have a cursor, etc. Essentially "less and cat but way better". Vim can certainly do all these things (or mostly, I don't know about the terminal colors), but for viewing read-only text streams, it's a bit more domain-specific and convenient. It's also blazing fast to open, which vim isn't always.
- alpisec 7y agoThank you for sharing - sometimes you can save a lot of time just with highlighting.
- temo4ka 7y agoThis post is relevant: https://news.ycombinator.com/item?id=17874718 https://news.ycombinator.com/item?id=17874718
- myartsev 7y agofzf + bat seems pretty nice! export FZF_DEFAULT_OPTS="--ansi --preview-window 'right:60%' --preview 'bat --color=always --style=header,grid --line-range :300 {}'"
- jeromescuggs 7y agoi really wish spacemacs didn't have that pretty lame loading screen, as a spacevim devotee i found alot of things that spacemacs does that specifically address some issues i have with spacevim. i know the correct path forward here is, of course, diving into the guts of spacevim and tinkering until it works for me, but i will post one quirk as it will probably be some time before i will be able to write my own comprehensive plugin: the hugofy/markdown plugins seem to all do this awful thing in which they render the markdown on the fly. it's kinda neat for basic text formatting, but my god it is an utter nightmare if you have any sort of URL's or images, because the second you key in that second bracket, it suddenly dissapears and you're left having to basically guess your way through the process of typing the url and closing out the shortcode. if someone knows of a markdown editor that plays nice, i'd love to see it. hope im not overlooking something painfully obvious here anyways, i picked a hell of a time to dive into the commandline, a year ago i came across scoop/chocolatey and quickly discovered WSL, and thanks to a phenomenal amount of work by some great folks (even you, Person Reading This), my desktop is not much more than the lobby i pass through before going to where the magic happens: https://imgur.com/a/iCpWZAC https://imgur.com/a/iCpWZAC
- weaksauce 7y agoWhat about the loading screen do you dislike? I believe you can change the default after it loads up(and you generally want to be using a daemon in the background with Emacs so it’s a first time run thing mainly anyway)
- z3phyr 7y agoWhy are dark themes considered cool? Am I missing something?
- C0d3r 7y agoEasier on the eyes, at least for me.