Hacker News new | past | comments | ask | show | jobs | submit | greenspot's comments login

OT: Who has experiences with serverless and which providers/services could yoi recommend?


I do, and if you are building a large app, I would recommend against using serverless. At least the library, since it has a limit of about 20 endpoints unmodified.


I did not know that, could you share a proof to back this statement ?


Try adding 40 endpoints to one serverless.yml file. You will quickly run over the 200 resource limit for cloudformation.

Actually, now that I think of it, since this is an AWS limitation, it may actually be fine on other providers.


I guess the limit could be avoided by using only one endpoint and use the path and HTTP method to decide which logic to execute though.


Could quit FB (took around 2-3 years and wasn't easy) but now I am super addicted to some Reddit subs such as r/mechanicalkeyboards.

Addiction is higher than with FB but it doesn't make me feel miserable.


I have same problem with hacker news after I quit FB lol


I believe that's what is called a hobby.


I wouldn't class looking at hobby subreddits a hobby. Actually building, replacing keys, fixing or taking photos of keyboards is the hobby part.


Celeste, one recent major indie game, was started and initially developed on Pico-8.

If are into games, check out Celeste. Just the music is reason to play this game (I played it on PS4 but all versions are equal).


This. So true and extremely well framed.

The only thing I can add: At the beginning of a relationship, everybody is kind. Background checks not just help, they are essential, do them.

Getting into conflicts and power plays with VCs, or just any person at some point, should be expected but there are still huge differences in how people deal in messy situations in terms of morale and ethics. You will find everything between feeling uneasy and facing a nuclear war.


>>> there are still huge differences in how people deal in messy situations in terms of morale and ethics.

so true. Problem is that in my small business experience, those in power are there because they have very flexible views on morale and ethics (i.e. they think they have morale/ethics, but they actually forget it when their company is at stakes). Being the ethical guy I'm of course totally biased. But the parent post is so right : having ethics/morale can be extremely damaging for you because you'll have to work with people who absolutely don't get how you think and that'll be super exhausting. Know yourself before going into that game.


I like to extend the question: Which online mail provider has many or just some third party integrations, in particular those offering mail merge and per recipient email tracking.

Gmail is here unfortunately by far the leading product.


I am bit surprised about this article. The momentum around AMP slowed down. AMP pages do not rank that well anymore as when they were introduced. Also within Google, there is no unanimity about the future of AMP. But maybe I got the signals wrong.


Google is abusing its powers. The search rank is our currency and Google has pushed AMP sites to the top for some while. So, everybody is now building weird AMP layers for their sites. We went from a free to a proprietary mobile web in just a few weeks. And we can't do anything. It feels like the times when the Internet Explorer tried to rule except that more people were complaining.

The open solution to a faster mobile web would have been so easy: Just penalize large and slow web pages without defining a dedicated mobile specification. That's it. This wasn't done in the past, slow pages outperformed fast ones on the SERPs because of some weird Google voodoo ranking, heck sometimes even desktop sites outperformed responsive ones on smartphones. If they had just tweaked these odd ranking rules in way that speed and size got more impact on the overall ranking there wouldn't have been any reason for AMP—the market would have regulated itself.

I'm wondering who at Google is responsible for AMP. Who created AMP's random specs (no external CSS but external fonts files, preference for four selected font providers, no JS but their JS, probable ranking preference of Google cached AMP sites, etc.). Why did they decide on the spec themselves and not as a part of an industry group? Again why didn't they just tweaked their ranking algorithm and btw, they could have also made Android's Chrome faster, it's still significantly slower than iOS' Safari. I'd be happy if this person could comment on the abuse of power (Sundar Pichai?).


> The open solution to a faster mobile web would have been so easy: Just penalize large and slow web pages without defining a dedicated mobile specification

It's obvious they have a different view on this. You can see this first-hand on their pagespeed tool. Pagespeed ranks your pages mostly according to random features, irregardless of size and performance. Actual test you can perform: 1kb web page with no compression ranks lower than 1mb web page after compression: "because you should enable server-side compression".

Their mobile assessment tool is similarly a joke.

The sad thing is that I'm likely getting a lower ranking on my website with has 5kb vanilla uncompressed js (gasp, not even async!) compared to the glittered rating of a 5mb homepage which loads 5mb+ more excluding webfonts from external CDNs.

You can taste that this has spread into google monoculture by the performance of their own web services.


>You can taste that this has spread into google monoculture by the performance of their own web services.

I gave up on Google Maps a long time ago. On my desktop or laptop, it loads in chunks. Like, the map loads, then the search bar loads, then the navigation (zoom tools, etc) loads. When I click and drag, many times I end up selecting the page instead of moving the map because it hasn't finished loading. I use Bing Maps on desktop and Apple Maps on mobile, only using Google Maps when I need to verify an address is the right place or find a company's hours, since their data is better than their competitors.

But man their performance is worse. Way worse.


They have a "google maps lite version" that loads a little faster, because it misses a bunch us useless crap, but looks 90% the same. It feels somewhat faster.


Link?


regardless


> I'm wondering who at Google is responsible for AMP. Who created AMP's random specs (no external CSS but external fonts files, preference for four selected font providers, no JS but their JS, probable ranking preference of Google cached AMP sites, etc.).

A bunch of people, but Malte Ubl is one of the main people and has the best tech talks on why they picked the techniques and hacks they did.

https://www.youtube.com/watch?v=cfekj564rs0

I'd recommend watching that for how it works than asking @amphtml questions.

Node people: I did a node specific presentation at LNUG you might like:

https://mikemaccana.github.io/quick-wins-with-node-and-amp/#...

I use AMP on CertSimple but appreciate that AMP favors 'speed achieved using specific techniques' rather than speed per se. There's the RealPolitik element where we as site owners have to do what Google say.


>I use AMP on CertSimple but appreciate that AMP favors 'speed achieved using specific techniques' rather than speed per se.

Why on god's name anybody would appreciate that?


I believe the poster means appreciate as in 'I recognise that' or 'I understand that' rather than 'I approve of'.


Yes.


> "The open solution to a faster mobile web would have been so easy: just penalize large and slow web pages, without defining a dedicated mobile specification."

A million times yes. As to why this didn't happen, I feel it would have been too restricted to "merely solving the problem", and not active enough on pushing Google's agenda to tighten its control on the web.

All other things being equal, option A being "efficient & neutral" (just penalize slow pages) is, as a business, inferior to option B "more convoluted but with potentially profitable side-effects" (AMP).

Other takes?

EDIT I should have better read the linked article before posting this, what I'm writing here is close to what the article "Lock In" section says.


> Google is abusing its powers.

They are a business, doing exactly what they are supposed to be doing.

It's up to us to find a way to kill google and take back our internet.

Edit, i love the downvotes for this. Google is legally required to act in their shareholders best interests. You all should understand fiduciary duty. They are building long term value for a massive (and growing) customer segment at the expense of a relatively small base of idealist tech users. Its morally reprehensible but still the correct decision in today's business climate.


You're right, but that point isn't relevant.

What you're giving is an explanation, not an excuse. Nobody is incredulous at Google's motivations (money). We're just not satisfied with it.

Before you can solve a problem, you must identify it clearly. That's what we're doing here. Saying "yeah but it's only logical" isn't the point. Look:

> It's up to us to find a way to kill google and take back our internet.

You mean, like discussing why AMP is bad and why we shouldn't use it?


But we don't need an excuse. However the explanation seems necessary given that:

- we saw it happen once;

- we said it would happened again;

- we said how;

- we said why;

- and it happened again.

And apparently nobody gives a damn. People are still trying to get short term gains by adapting to Google's will and wrecking our industry, efficiently sawing the branch we are all seating on.

So yeah, we need to give the explanation. Again. And again. Until people hear it.

We are responsible of the situation.

Not Google. Before Google there was others like MS, and after they will be others. It's like a disease. You don't blame diseases, it's very useless, you explain, and you act.

Yes, your site will not make as much money. But for God sake, it's the same rational for green energy, criminal prevention and the like. You pay NOW because you understand that it's necessary on the long run.


> Before Google there was others like MS, and after they will be others

MS had their cases in court where they had to pay a lot of money for violating laws. Maybe it's time for Google to go through the same phase.


It didn't change MS. They just adapted. Now they have better PR, so people comes to HN, reddit and imgur to sing their song for them instead of doing quircky adds. Right now Gates is having so much praise it's like he is Mandela and Buddah's outspring.


You are making an assumption (an incorrect one, I think) that providing explanations causes people's behavior to change.


You are kinda right. But not making sure the explanations keep being spread does make it easier to forget or ignore it, and even fewer people would care. It's not a good strategy to gain traction, but not doing it make you loose it even more.


No, everyone on here shouldn't need explanation on why amp is bad.

Especially when its a closed system that Google insists serving to your customers from Google's private servers. No technologist or business person would/should ever stand for that. Yet we are forced to.

The discussion should really be, how do we dislodge Google from its current entrenched position.


Uh, use a different search engine? Am I missing something?


Yeah, a whole host of technical and legal methods that go beyond an incredibly hard collective-action problem.


>They are a business, doing exactly what they are supposed to be doing.

There was such a thing as ethical and societal responsibility for businesses.

Thinking making profit by any means as long as they are nominally legal is acceptable for a company is just something some people believe. No natural law that says it has to be so -- we could easily (and have had) believe the opposite.


>There was such a thing as ethical and societal responsibility for businesses.

Since when? Standard oil? Or going back further, the Dutch East India Company?


Since the time companies started being held accountable.

Which goes back all the way to ancient Babylon in some form or another. There are countless instances in history of shady businessmen being taken to trial or punished by an angry mob.

(And the "Dutch East India Company" was accountable to its society -- and even nationalized at some point. It just exploited OTHER societies and countries).


And "Google" was accountable to its shareholders -- and even made public at some point. It just exploited OTHER parts of society.

See?


Corporate social responsibility want a thing on the silk road, but we expect it now.


> They are a business, doing exactly what they are supposed to be doing.

Violating anti-trust laws?


Anti trust prosecutions work only if harm to consumer is proven - harm to other companies doesn't really work for successfully anti trust prosecutions.

There's a reason no US attorneys bring anti trust lawsuits against Google and that's because Google would very likely be able to show their choices benefitted consumers (eg. say saved 10 mins and 50MB data a day across 200 million consumers without charge)


I'm an individual, not a company. I make web pages. Lots of other individuals also make web pages. It's not like only companies make websites and consumers only use websites.


I'm pretty sure the number of individual web devs is vastly lower than the number of consumers.


Maybe, I don't know. My point was that Google fucking with the web doesn't only affect companies. Even if there's vastly more company websites than personal websites, there's a vast number of personal websites too.


What would the process of being convicted of anti-trust laws for a website, when in order to use a competitor, you just have to type 'bing.com' or 'duckduckgo.com' into your address bar?


If using competitor is not viable. Similarly, one could have installed an alternative OS with an alternative browser in 2000, but the jury thought that it's not that simple.


I'm no google fanboy, but they haven't been convicted of violating any antitrust laws here in the US.

Edit: Again with downvotes. Have I made an inaccurate statement?


FYI: Although I suppose everyone every once in a while is surprised about the way their posts are moderated on HN and other websites (if they notice, that is) it is annoying when people complain about downvoting. I just automatically downvote that.

Sometimes what you state just isn't popular for the crowd who reads it and/or moderates it. Doesn't mean you are right or wrong. Just take a deep breath and give it a rest.

EDIT: The guidelines say: "Please resist commenting about being downvoted. It never does any good, and it makes boring reading." https://news.ycombinator.com/newsguidelines.html hence, nope, I won't change that unless someone who works for HN directs me to.


> I just automatically downvote that.

We can both agree that one of us needs to change.

The guidelines are fine, the part you should change is automatically downvoting anything. Just jumping on a bandwagon makes for pretty boring reading too.


hint: it's you


You don't have to be convicted to be violating, because:

1) Not all violators will necessarily be convicted.

2) Even for those eventually convicted, there's always a period when they are violating, but not yet convicted.


Guilt before innocence, got it.


Being guilty before proven guilty is a thing in the real world.

As is being guilty and getting away with it. People do that all the time too.

And courthouses and judges don't have some monopoly into assessment of guilt. Just into its official identification and punishment.

(If the legal system had the monopoly, or some moral monopoly, of only it determining guilt, then how would we, as a society, judge the effectiveness or not of the legal system itself?)


> we, as a society

yes, we (the united states where google is head quartered) as a society, have agreed to at least pretend to allow the legal system to define guilt and innocence. But this isn't a philosophical debate. This is a discussion of what can be done to fix the AMP dilemma.


Criticizing Google too strongly e.g. kill google is a surefire way to get downvotes. Which is pretty much the same logic you described. HN is frequented by googlers, even if it is not exactly a duty to downvote comments like yours, it makes some sense. Or maybe I'm just seeing things.


> required to act in their shareholders best interests

This is an extremely vague requirement. Potentially killing their brand name among developers and potentially initiating a slow long decline into irrelevancy certainly counts as not acting in their shareholders' best interests. When google first started, their "don't be evil" mantra was one of the main reasons they succeeded, so not doing unethical shit is in their shareholders' best interests.


> Potentially killing their brand name among developers and potentially initiating a slow long decline into irrelevancy certainly counts as not acting in their shareholders' best interests. When google first started, their "don't be evil" mantra was one of the main reasons they succeeded

He's right in that they're a company, but not that the solution to this problem is to "kill Google."

Much easier and truer to the problem is to "kill" this expectation people have that the magic of good-natured leadership will create companies that dutifully remain bound to arbitrary constraints as "don't be evil" or "not doing unethical shit". It's just blissful daydreaming.

Much better would be to collectively gravitate around community alternatives. You have most of the tools in front of you (open-source, remember?), but you decide that Google's 'already won' and think of yourself as reliant upon them (thus complaining when they don't do things your way).


No, making more money is, and shareholders tend to think in short term gains.


Are only short term gains in shareholders' best interests? Is there a legal definition? I'm asking genuinely.


No, they are not. This is a common misconception.

http://www.nytimes.com/roomfordebate/2015/04/16/what-are-cor...


> You all should understand fiduciary duty.

We do. You should understand it. http://www.nytimes.com/roomfordebate/2015/04/16/what-are-cor...

The interpretation of "fiduciary duty" / "they are a business" that you're implying is an urban legend, easily debunked by the fact that Google has no fiduciary duty to open a gas station in rural North Dakota as soon as they realize from Google Maps data that one would be profitable.


>Its morally reprehensible but still the correct decision in today's business climate.

Using your logic if slavery were to become legal again, businesses should rush to use the free labor because "fiduciary duty".

This is why they teach business ethics.


Why do you think companies rush to use H1B visas and offshore to countries that use (what amounts to) slave labor?

Yes, companies do this today. Business ethics counts for nothing if it's not mandated. Compare Walmart's revenue to Whole Foods and you'll see why.


I don't quite understand how you're putting a moral judgement on outsourcing which is simply the purchase of a service. Certainly if a specific company is using slave or even child labor that is terrible and they should be boycotted. There have been several cases of business suffering real consequences. I am sure that they have not escaped your attention.

Anyway, its wrong to say business ethics account for nothing. Companies can and do self-regulate. e.g. http://www.hbs.edu/research/pdf/07-023.pdf


Where did I put a moral judgment on all outsourcing? I put a moral judgement on outsourcing to countries that use slave labor, obviously in the context of using slave labor (which is the subject of the thread I'm replying to).

That was entirely clear from my comment, and you deliberately chose to ignore that. I will not apologize or make corrections.


Well, I took your comment charitably and addressed the point about individual companies employing abhorrent practices (whether it be labor or otherwise). Obviously, we're not in favor of that.

But your claim seems to be that an entire technological sector spanning multiple countries employs slave labor? Its hard to take you seriously at this point.


Again, I never claimed anything that you're saying I claimed. You're taking my comment charitably? Hardly.

My claim is that many companies use (what amounts to) slave labor and that there are financial incentives and economic structures designed around this. It's hard to compete without it, since your competitors are going to be using it. As one example, take entry level programmers on an H1B visa making less than their American counterparts, living with three other H1B roommates in a two-bedroom apartment, sharing one car, working 80 hours a week, knowing that if they get fired they get deported. Or Chinese workers unable to quit but working such horrid conditions that they kill themselves to get out of having to work. Or children in Africa making clothes to sell at Walmart in Illinois.

But again, that's just exactly what I said originally. I literally cannot make my opinion any more clear, so if you're still confused the only thing I can conclude is that you're deliberately misunderstanding in order to provoke an argument, something that is far too common on HN. I don't care if you take me seriously. I care as much about your opinion as you seem to care about mine.


Okay, never mind. We'll just have to bury it here. No point arguing over nothing. Have a nice day. :^)


Fiduciary duty it isn't a magic spell that shareholders cast and then the company does everything all the time to squeeze profit out of everything. Lots of Google services are still free (as in price)


No, they are adware. Or "get monitored and profiled".


You should understand fiduciary duty vs corporate director responsibility.

Best interest != monetary gain.

http://www.nytimes.com/roomfordebate/2015/04/16/what-are-cor...


If "you" use Chrome, then Amp is your fault. You gave an advertising company control of the Web.


AMP and Chrome are two completely independent things.


Controlled by the same company to further the same goal.


More like "if you use Google". Sadly, nobody has built just as good alternative search engine. Or as nice webmail.

Generally, Google has huge resources to spend at making their search and their advertising platform outperform others, and they haven't degenerated enough to allow a swift moving company to disrupt their market.


The crazy thing is that AMP is open source and this is still happening. I've been tracking their GitHub and what is happening is that while yes, the source is open, they won't let you add anything they don't like.

Oh, and if you try to fork AMP you fail the official validators and suddenly your site isn't AMP anymore. What is happening in this case is that open source is doing nothing to stop AMP from being proprietary because it's worthless unless you have the "blessed" version.

Take for example the most obvious change, to make the original URL visible in the banner. There's tens maybe hundreds of GitHub issues on this and it's still languishing. In the rare case anyone official replies it's some bs about how it will affect the user experience or "interfere with Google's cache" in some roundabout and unspecified way. They leave a few of these issues open so that whenever you start another they can close it as a duplicate. Otherwise their repo would be overrun with them.

Open source doesn't matter if someone holds the keys to the kingdom and "validates" your sources. A dark pattern indeed.

AMP in its current form is certainly evil. The only way that could be changed is if Google opens up the ability to cache the page by a different provider with different validators.

I smell antitrust


> I've been tracking their GitHub and what is happening is that while yes, the source is open, they won't let you add anything they don't like.

Well, thats basically how Android works.

And with the upcoming policy changes (in CDD and GCM) things will get even worse.


There's a difference with Android, though: with Android, you can modify the source and use it on your own devices (which might be not be super easy, but it's doable).

With AMP, you can modify the source and ... ... run your own search engine???

Android is software in the traditional sense. AMP is a protocol, even though it's phrased as software. The principles of free software apply to software, and protect your freedom when applied to software. They don't work right when applied to protocols.


It's pretty much how open source works everywhere - you have to convince the maintainer to adopt your code. If they don't, you've got the options of either being sad or forking it and trying to get people to use your subjectively better version.

It's open source, not anarchist source.


In the case of AMP the only source that works with google is the official one. As soon as you fork it's not "AMP" compatible anymore.

You see the other half of AMP is completely proprietary and runs on Google's servers. It doesn't matter that you can edit AMP because the server (Google's end) will refuse to run your edited version.


Yes, which is what I implied: open source software is fine and good if it's used in a decentralized fashion.

But if it's just a provider open sourcing the implementation of their communication protocol/operating system running on their devices, it's good for the community that they can look into it and learn; but just as well, it doesn't imply that any of the changes you're able to make actually do anything.


But have anyone been able to convince the Android team of anything?

They are not even listening to the Linux team with their thousands of highly qualified developers and are essentially running their own fork of the kernel where everything has to be done The Google Way (TM).


Could you tell me about those changes?


I am under NDA so I cant give you specifics but the general theme of the changes are: less power to manufacturers, more to carriers.


> less power to manufacturers, more to carriers.

What about the owners of the phones? I pay money — good money, quite a bit of it — for my phone. I own it. It should do exactly what I want, not what Google, Apple, Samsung, Sprint, Verizon or T-Mobile want.


Well, this change will limit what Samsung is allowed to customize, maybe thats a good thing? But everyone else with get more powers.


Isn't this just another variety of Tivoization? The platform is nominally open source, but unable to run anything other than approved code.


Do you have a specific example of a rejected pull request or feature? It seems also possible that people outside google aren't contributing for other reasons, like lack of interest.


Is 'not finishing' an inherent problem of being a coder and a coder's reward system?

When I look at myself, coding is great when I learn new things, new APIs, can glue stuff together to create new systems which haven't been there before. Once I master a technology or have to do stuff which was done million times before it gets boring. Then, I rather seek for the next kick, the next API, the next language/framework/lib.

So, having ongoing novelties seems to be an important part of a coder's reward system. This hurts finishing and going the last mile, the most difficult part of a project that is not about facing steady novelties. Often it even means to abandon the shiny new tech and rebuild stuff in some proven tech.

However, the bad is you never finish, the good is you learn all the time. Better than checking Facebook, Instagram and your smartphone 24/7.


I find this as well. My motivation for new projects is 100x compared to my motivation to finish existing ones, and I feel part of it at least is because on the existing ones I've reached a point where I'm not learning anything from finishing them. The flipside is that I have a lot less work that I can point to having done, compared to how much I've actually done. Having 5 completed things to show is better (for "achievement" purposes) than 20 projects at 80%, but the rewards as you say favour the latter.

This year I'm thinking about only working on projects where I'd actually use the outcome for something. If it's a project for the sake of learning library X, I won't do it. If it's a project to solve problem Y for myself, I'll try and work on that, learning anything I need along the way.


Great post & thread, a tl;dr:

  Ctrl-r      search history
              - then Ctrl-r again to show next match
              - then Tab to show all options
  Ctrl-p      previous command or arrow up
  Ctrl-n      next command or arrow down
  export HISTCONTROL=ignoreboth:erasedups
              Add to .bashrc to avoid duplicate entries

  Ctrl-a      to beginning of line
  Ctrl-e      to end of line
  Alt-b       one word back
  Alt-f       one word forward
  Ctrl-k      delete to end of line
  Ctrl-u      delete to beginning of line
  Alt-d       delete to end of word
  Ctrl-w      delete to beginning of word
  Alt-Backspc same

  cd -        change to last dir
  pushd <dir> mark current dir and go to <dir>
  popd        go to marked dir 
  z           fuzzy cd, install from https://github.com/rupa/z
  j           fuzzy cd and more, install via autojump

  Ctrl-z      to background & suspend
  bg          recent background app continue running
  fg          bring recent background app to front
  disown -h   remove recent background app from current tty
  fg %n       bring nth app to front, e.g.: fg %2 for second

  less        better than cat, doesn't flood screen, same keys
  find        find files, e.g. find / -name <filename>

  ag          install via the_silver_searcher, faster grep

  tree        shows dir like a GUI app, install
  !!          last command, e.g. sudo !!
  fish        bash alternative with more sensible defaults

  man bash    read more about bash


There is Ctrl-y for pasting deleted strings, which goes along very well with these commands:

  Ctrl-k      delete to end of line
  Ctrl-u      delete to beginning of line
  Alt-d       delete to end of word
  Ctrl-w      delete to beginning of word
  Alt-Backspc same
Bash keybindings behave like Emacs by default, hence every time you invoke one of these, it will put the string into a buffer, which can be later pasted using Ctrl-y.

This is very useful. For instance, if you remembered that you didn't `mkdir /mnt/disk` while in the middle of the command `mount /dev/sdb /mnt/disk`, you can delete what you have already typed with Ctrl-u; issue `mkdir /mnt/disk`; than you can paste the previous command with Ctrl-y. Very useful and I use it all the time! (Ctrl-u have never tied to my muscle memory, so I usually do Ctrl-a Ctrl-k to move to the beginning of the line and delete what comes next).

Other tips:

  cd            goes to home dir
  Ctrl-]        moves cursor to character (such as vim f)
  Ctrl+Meta+]   moves to character backwards (vim F)
I also put these in my .bashrc for searching history pressing up/down.

  "\e[A": history-search-backward 
  "\e[B": history-search-forward 
This is different of searching with Ctrl-r. When you type part of a command, such as

  mkdir /dev
and press up, it will complete with previous ocurrences of commands starting with `mkdir /dev`. It is faster than Ctrl-r if you already know what to do.


  "\e[A": history-search-backward 
  "\e[B": history-search-forward 
These have to go in `~/.inputrc`, right?


That's right! Sorry for the late reply.


Here are some notes I took about ZSH that may be helpful to someone

* zsh bang

previous commands:

   !!  Previous command
   !-1 Previous command
   !-2 Second previous command
Getting individual arguments:

   !$   Last arg
   !*   All args
   !$:h Last argument, strip one level
   !!:1 First arg
Modifying commandlines

   !ls:$:h             Head
   !ls:$:t             Tail
   !ls:$:r             Rm Suffix
   !ls:$:s/user/dude/  Substitute user by dude
* Filename Modifiers

  :h	head (dirname)
  :t	tail (basename)
  :e	extension
  :r	remove extension

  :l	lowercase conversion
  :u	uppercase conversion

  :p	print command but do not execute
  :q	quote substituted words

* zsh globbing

  **/* 	Picks out all files and directories, recursively.
  ***/*	Ditto, following symlinks
  *	Any string, including the null string.
  ?	Any character.
  [...]	Any of the enclosed characters. Ranges of characters can be specified by
  separating two characters by a -.
  [^...]	Inverse
  [!...]	Inverse
  <x-y>	Any number in the range x to y, inclusive. Either can be omitted.
  ^x	Anything except the pattern x.
  x|y	Either x or y.

  x#	Zero or more occurrences of the pattern x.
  x##	One or more occurrences of the pattern x.
globbing qualifiers

* file type

    (.) 	Regular files
    (/)     Directories
    (@)     Symlinks
    (=)	Sockets
    (p)	Named pipes
    (%)	Device
    (%b)	Block devices
    (%c)	Character devices
* permissions

    (r)     Readable by owner
    (w)     Writable by owner
    (x)     Executables by owner
    (R)     Readable by world
    (W)     Writable by world
    (X)     Executable by world
    (A)	Readable by group
    (I)	Writable by group
    (E)	Executable bu group
alternatively a chmod style syntax is supported:

    ls **/*(.:g-w:)
* Ownership

    (U)		Your own user
    (G)		Your own group
    (u:userid:)	User with userid
    (g:userid:)	group with groupid
example: list files belonging to user www-data with ls -l /(u:www-data:)

Modification and access time

    (m)	Modification time
    (a)	Access time

    (-)	Before
    (+)	After

    (M)	Months
    (w)	Weeks
    (h)	Hours
    (m)	Minutes
    (s)	Seconds
example: list files accessed last month with ls /(.aM-1)

file size

    (L)	File size (defaults to bytes)
    (k)	use kilobytes
    (m)	use megabytes
    (p)	use 512-byte blocks
example: list all files larger than 10 megabytes with ls /(.Lm+10)

dos2unix /~.(gif|png|jpg)(.) # ~ excludes

dos2unix (#i)/~.(gif|png|jpg)(.) # case-insensitive

ls =bob # Lists file anywhere in $PATH

ls /some_file # Lists file under current directory zargs -- /(.) -- ls -l # Ditto

* zsh Iteration

  for i (/home/**/q*) rm $i
  for i in /**/b*(u:miklophone:); do rm $i ; done
  for f in http://zsh.sunsite.dk/Guide/zshguide{,{01..08}}.html; do...
  zargs -- /**/b*(u:miklophone:) -- rm

* Renaming files with Zsh

Numerical prefix:

   $  i=1; for j in *; do mv $j $i.$j; ((i++)); done

   $  i=1; for f in *; do mv $f $(echo $i| awk '{ printf("%03d", $0)}').$f;
   ((i++)); done

   $  integer i=0; for f in *; do mv $f $[i+=1].$f; done
Rename all files from name.mp3 to Name.mp3:

   $  zmv `([a-z])(*).mp3` `${(C)1}$2.mp3`
Capitalize file

   $  zmv '([a-z])(*).pdf' '${(C)1}$2.pdf'
Replaces spaces with underlines

   $  zmv '* *' '$f:gs/ /_'
FOO to foo

   $  for i in *(.); mv $i ${i:l}
Rename pic1.jpg to pic0001.jpg ...

   $  zmv 'pic(*).jpg' 'pic${(1:4::0:)1}.jpg'
   $  zmv '(**/)pic(*).jpg' '$1/pic1:4::0:)2}.jpg'  # recursive
Remove spaces from filenames

   $  for a in ./**/*\ *(Dod); do mv $a ${a:h}/${a:t:gs/ /_}; done
Substitute r for l

   s/l/r[/]

   Unless preceded immediately by a g, with no colon between, the
   substitution is done only for the first string that matches l. For
   arrays and filename expansion, this applies to each word of the
   expanded text.

   The left-hand side of substitutions are not regular expressions,
   but character strings.

   Any character can be used as the delimiter in place of '/'. A
   backslash quotes the delimiter character.

   The character '&', in the right-hand-side r, is replaced by the
   text from the left-hand-side l. The '&' can be quoted with a
   backslash.

* zsh if # see also -z below

  if [[ $foo = '' ]]; then
  print The parameter foo is empty
  fi
# quote the term to avoid pattern matching (not regexp, btw)

  if [[ biriyana = b* ]]; then
  print Word begins with a b
  fi
# Numbers

  if [[ $number -gt 3 ]]; then
  if [[ $number -lt 3 ]]; then
  if (( $number > 3 )); then
  if (( 3 )); then
# Files

  if [[ file1 -nt file2 ]]; then		# newer than
  if [[ file1 -ot file2 ]]; then		# older than
  if [[ file1 -ef file2 ]]; then		# same file
# Variables

  if [[ -z "$var is blah; test fails" ]]; then		# zero length?
  if [[ -n "$var is blah; test passes" ]]; then		# non-zero length?


For all but the simplest renaming tasks, I use "qmv" (from the renameutils[1] package). It loads up the target filenames/paths in a buffer in your $EDITOR, and then you can use the full power of your editor to rename. When you save the buffer, qmv does a sanity check and then does the actual renaming.

Here's a simple example: [2], but it can get arbitrarily complex -- in a much more visual and interactive way than what a shell alone would be capable of.

[1] - http://manpages.ubuntu.com/manpages/wily/en/man1/qmv.1.html

[2] - http://unix.stackexchange.com/questions/1136/batch-renaming-...


Ctrl+l clears screen. This is very useful even if you are inside a REPL like python, ruby, mysql, etc...


tl:dr

  ctrl-r     search in history, ctrl-r again to skip-
  ctrl-p     previous command (instead of arrow up)
  ctri-n


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: