Earlier quoted context omitted.
Mmh, what do you mean with "preserve"...? `cd -` works like a charm for me.
"cd -" changes to the previous working directory. Your function calls cd multiple times, so calling "cd -" won't bring the user to the previous working directory they expect. ozym4nd145's function only calls cd once.
Command line tools for productive programmers
101–110 of 143 posts
Re: Command line tools for productive programmers
#102This is productivity porn for programmers. While obviously these tools are deep and powerful, there is also a learning curve and experimenting wether you can adapt your workflow to them or vice versa. Next year we will have another 5 shiny command line tools, and so on. My point being: only replace your weapons of choice once you are confident you are using them to their full potential and you identify needs that the…
Same with fzf. On a Mac, copying specific output from a command becomes so easy. For example `git branch | fzf | pbcopy`.
Re: Command line tools for productive programmers
#103I can't sing the praises enough of entr. Just check out its man page: http://eradman.com/entrproject/ entr lets you watch files and re-run a command any time they change. Whenever I'm working on a script, or go tests, or whatever test-like thing I'm doing that's not in its own bloated test harness, I reach for entr. Great software, does what it's supposed to every time.
Re: Command line tools for productive programmers
#104I've historically spent all my days SSH'd into a remote server in a screen/tmux session writing code in vim and doing various admin/db tasks. Recently I started using vscode with the remote-ssh plugin and it has surprisingly been a pleasant experience. I have an integrated terminal to the remote box and I have full intellisense for coding (I do 80% coding / 20% admin, probably). It took a gestalt flip for me to reali…
Re: Command line tools for productive programmers
#105-sox, audio swiss knife
-ffmpeg, ditto for video
-ncdu, check disk usage
-rclone, mount and rsync everything
-f3, check and forbid overwriting those fake USB drives
-udfclient UDF, but better as it eases compabitibility. Ditch fat32/NTFS for computer media sharing
-trickle For network/web programmers, it can force really slow connections on software, such as 2G/ISDN speeds and even below. Perfect to test bad conditions
-pdftotext -layout It dumps a whole PDF into a text file. Useful for copy/paste or adapting the format to anything else - unzip -qcp "$EBOOK_BOOK" "ml" ".htm" | lynx -force-html -dump -stdin -nolist > book.txt EPUB to utf8 dumper.
Trivially adaptable to be used with less, for example. Use "$1" instead of "$EPUB_BOOK" to use it on a script.
Re: Command line tools for productive programmers
#106Earlier quoted context omitted.
I don't want to be That Guy who says his way is best but I can only really see this being useful for someone who knows no shell tools at all. > ps -A | grep ruby | grep fsevent | ruby-each-line "puts l.split.first" | xargs kill -9 killall -9 -r ruby.\*fsevent > cat c | ruby-each-line "puts l.split.first[0..-2]" >> .env.development awk '{ print(substr($1, 0, length($1) - 1)) }' c >> .env.development or awk '{ print $1…
That first pkill/killall example is a bit silly, but for the others I can see how a "ruby-each-line" can be useful, especially if you're already familiar with Ruby (although I'd probably name it "el", as that's much less typing). I never really learned awk properly myself either, in spite of being quite familiar with most other shell tools. "ruby-each-line" does more or less the same thing as awk. After all, there's…
> I never really learned awk properly myself either
It's really worth it. It's simple — pattern matches and block, BEGIN/END, hashes, match() and gsub() cover 90% of my uses. I very often find myself writing something like this:
awk -v id=$id '
$1 == id {
go = 1
}
{
if (go && $4 == "b667226") {
km += $5
secs += $6
n++
}
}
END {
printf("%d rides, %d km (approx %.1f hours)\n", n, km / 1000, secs / 3600)
}'
This program takes STDIN, reads each line and:* sets a flag indicating interesting data has been found if the first column matches an ID passes on the command line * if the flag is set and column 4 contains "b667226", add columns 5 and 6 to running totals, and add 1 to a count of matching lines * after all the input has been read, prints out a summary of the data
Of course, any language can do something like this, but awk is succinct, easy to iterate on, and available almost everywhere.
Re: Command line tools for productive programmers
#107The single best improvement to my command-line workflow I've done in the last few years has been switching shells. First I moved from Bash to ZSH, but about 2 years ago I switched again to Fish.
Why I love it: - history completion searches by default, so I can just type part of a command, hit arrow-up and look through only the relevant results (ZSH also did this, but Fish is better)
- tab completions are shown to you in advance (in light gray in front of your cursor)
- Basic configuration (which is good enough, honestly) can be done via a web browser. Just run "fish_config", and it starts a web server, pops open your browser and any changes you make there are saved to your actual config files. No more looking up syntax.
- aliases (which are called abbreviations) are actually expanded after typing, so the full command appears in your history. You can also edit the full command before running it, if you need.
Re: Command line tools for productive programmers
#108I've historically spent all my days SSH'd into a remote server in a screen/tmux session writing code in vim and doing various admin/db tasks. Recently I started using vscode with the remote-ssh plugin and it has surprisingly been a pleasant experience. I have an integrated terminal to the remote box and I have full intellisense for coding (I do 80% coding / 20% admin, probably). It took a gestalt flip for me to reali…
Coming from remote development Emacs TRAMP, vscode + remote-ssh mercifully removed the cognitive load of dealing with Emacs. Not only do you not have to manually install & configure everything, vscode will tell you what you need and give you a working installation automatically.
Think before you downvote - is this incorrect, really?
Re: Command line tools for productive programmers
#109> if the directory has many files or sub-directories, tree becomes much less helpful: you only see the last screen full of information as files scroll past you. > broot solves this problem by being aware of the size of your terminal window and adapting its output to fit it. What? You can just pipe `tree` into `less`. The solution isn't to download Yet Another Binary that does this specific thing and doesn't come inst…
Use broot as tree is not necessary of course `tree | less` works for that but as hinted in the article broot contains a lot more features. Fuzzy finding, preview, multiwindow copy/paste, renaming, directory navigation etc
Re: Command line tools for productive programmers
#110I'm a VIM-only dev, spend all my day in a Tmux session, and I use the command-line probably a lot more than average. The single best improvement to my command-line workflow I've done in the last few years has been switching shells. First I moved from Bash to ZSH, but about 2 years ago I switched again to Fish. Why I love it: - history completion searches by default, so I can just type part of a command, hit arrow-up…