Defining the creative business of the 21st century

As a financial advisory firm specializing in creative businesses, we are often asked what defines a “creative business.” For many, the first thought that comes to mind are arts-based businesses…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Bash functions to level up your aliases game!

Do you use bash aliases to customise your commands?
Of course you do!

….

But, did you know you can extend aliases to use bash functions and pass arguments?

bash functions enables you to concatenate multiple commands and add as much arguments as you can. Well, just like any function in any programming language.

I came across this when i was looking into condensing git commands. I AM EXTREMELY LAZY, and running git add + git commit + git push every time, really hurts.

So let’s make a function that does just that.

STEP 1
— -
We need to make the alias persistent in bash profile.
Open a new bash terminal window and run :

STEP 2
— -
Anywhere in your bashrc file, declare the function as shown below.

STEP 3
— -

Save and exit nano.

Here is what we did, we declared `pushtoremote` function, which runs git add . git commit -m `message` and git push `repository` `branch` **consecutively**

`$1` `$2` `$3` are placeholders for the variables passed to the alias upon executing. `message` `repository` `branch` (example follows).

STEP 4
— -

We need to link the alias to the current session, so we can immediately start using it.

STEP 5
— -

Here is a sample command with `pushtoremote` alias.

*Note* : some terminals like `fish` do not support `&&` so you will have to replace it with `and`

If you make something extra cool with bash functions, please do let me know. :)))

I post snippets every day on twitter, join me there!

Cheers!

IYO

Add a comment

Related posts:

Sneakers as an asset class

The first pair of shoes were discovered in an archaeological digging 3300 years ago in the border between Austria and Italy archeologists found a naturally mummified human named Oetzi from the Stone…

Welcome to the Age of Monetary Exploration

Cryptocurrency is full of people who believe in old economic theories that have never been tried in the real world. There’s an almost zealous adherence to esoteric principles that seem to have no…

Mayoral candidates field questions

Mayoral candidates gathered at Oakland City Hall on Oct. 5 to field questions from voters about issues important to the future of the city. The forum was sponsored by the League of Women Voters, and…