FWIW the title says "functions", but it apparently uses aliases. Shell functions have all the same functionality as aliases and they'll catch more syntax errors upon "source myscript". Example: ls() { command ls --color=auto "$@" } is equivalent to alias ls='ls --color=auto' but IMO less error prone. You also get syntax highlighting. The only tricky thing is to remember the 'command' prefix if the "alias" has the sam…
Show HN: Redo – Command line utility for quickly creating shell functions
21–30 of 32 posts
Re: Show HN: Redo – Command line utility for quickly creating shell functions
#22Re: Show HN: Redo – Command line utility for quickly creating shell functions
#23I do this whenever working on terminal. The mnemonic is erc=edit rc, src=source rc. alias erc="vim ~/.bash_aliases" alias src="source ~/.bash_aliases" Whenever I need to add or modify some shell function or alias (or even make a quick note) I type erc to open the alias file. Then I type src to load it. Very handy.
http://www.modernperlbooks.com/mt/2009/10/remove-the-little-...
Re: Show HN: Redo – Command line utility for quickly creating shell functions
#24FWIW the title says "functions", but it apparently uses aliases. Shell functions have all the same functionality as aliases and they'll catch more syntax errors upon "source myscript". Example: ls() { command ls --color=auto "$@" } is equivalent to alias ls='ls --color=auto' but IMO less error prone. You also get syntax highlighting. The only tricky thing is to remember the 'command' prefix if the "alias" has the sam…
Re: Show HN: Redo – Command line utility for quickly creating shell functions
#25Re: Show HN: Redo – Command line utility for quickly creating shell functions
#26Earlier quoted context omitted.
Note there is one possibly important difference; aliases are resolved before globbing.
Hm what's an example of where you might want to take advantage of that? In practice alias 'lspy=ls *.py' seems to be interchangeable with lspy() { ls *.py "$@" }
You can make it an alias of * , / etc, so ...
$ * 4 6
24
$
It would keep it's own stack, but let a persistent process do the actual maths.The persistent process could almost any repl of python, ruby etc.
Or use a 'real' calculator like Pike's ivy; https://aplwiki.com/wiki/Ivy
Re: Show HN: Redo – Command line utility for quickly creating shell functions
#27Earlier quoted context omitted.
Hm what's an example of where you might want to take advantage of that? In practice alias 'lspy=ls *.py' seems to be interchangeable with lspy() { ls *.py "$@" }
I have a semi-made desk calculator with prefix notation. You can make it an alias of * , / etc, so ... $ * 4 6 24 $ It would keep it's own stack, but let a persistent process do the actual maths. The persistent process could almost any repl of python, ruby etc. Or use a 'real' calculator like Pike's ivy; https://aplwiki.com/wiki/Ivy
[ is a valid function name tho so fun could be had there.
Re: Show HN: Redo – Command line utility for quickly creating shell functions
#28Earlier quoted context omitted.
Hm what's an example of where you might want to take advantage of that? In practice alias 'lspy=ls *.py' seems to be interchangeable with lspy() { ls *.py "$@" }
I have a semi-made desk calculator with prefix notation. You can make it an alias of * , / etc, so ... $ * 4 6 24 $ It would keep it's own stack, but let a persistent process do the actual maths. The persistent process could almost any repl of python, ruby etc. Or use a 'real' calculator like Pike's ivy; https://aplwiki.com/wiki/Ivy
So you could use = to start the calc, and use infix or postfix notation.
Re: Show HN: Redo – Command line utility for quickly creating shell functions
#29FWIW the title says "functions", but it apparently uses aliases. Shell functions have all the same functionality as aliases and they'll catch more syntax errors upon "source myscript". Example: ls() { command ls --color=auto "$@" } is equivalent to alias ls='ls --color=auto' but IMO less error prone. You also get syntax highlighting. The only tricky thing is to remember the 'command' prefix if the "alias" has the sam…
I've always just written that as \ls to call the non-alias
$ function ls () {
> echo denied
> }
$ ls
denied
$ \ls
deniedRe: Show HN: Redo – Command line utility for quickly creating shell functions
#30hack hack, then run
nuscript-bash something
Hit C-x C-h, select some lines, edit, then run something
To do maintenance: edcom something
I wrote a little more about it here: https://blag.felixhummel.de/basics/bash/wrapper-scripts.html