3 added 608 characters in body
source | link

You could base your code on the built-in alias defined here

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(wrong_value),
            createaliasnode(ztrdup(right_value), 0));

(not tested)

And add source ~/.zsh_correct_aliases to you .zshrc


EDIT: tested with source:

char *aliaspath = getenv("HOME");
strcat(aliaspath, "/.zsh_correct_aliases");

FILE *out = fopen(aliaspath, "ab+");
fprintf(out, "alias %s=\'", *s);

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(*s),
    createaliasnode(ztrdup(best), 0));

*s = dupstring(best);
fprintf(out, "%s\'\n", *s);
fclose(out);
if (hist)
    hwrep(best);

It gives:

$ setopt correct 
$ dtea    
zsh: correct 'dtea' to 'date' [nyae]? y
lun. janv.  8 01:03:55 CET 2018  
$ alias  
dtea=date
$ dtea    
lun. janv.  8 01:07:42 CET 2018  

You could base your code on the built-in alias defined here

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(wrong_value),
            createaliasnode(ztrdup(right_value), 0));

(not tested)

And add source ~/.zsh_correct_aliases to you .zshrc

You could base your code on the built-in alias defined here

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(wrong_value),
            createaliasnode(ztrdup(right_value), 0));

(not tested)

And add source ~/.zsh_correct_aliases to you .zshrc


EDIT: tested with source:

char *aliaspath = getenv("HOME");
strcat(aliaspath, "/.zsh_correct_aliases");

FILE *out = fopen(aliaspath, "ab+");
fprintf(out, "alias %s=\'", *s);

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(*s),
    createaliasnode(ztrdup(best), 0));

*s = dupstring(best);
fprintf(out, "%s\'\n", *s);
fclose(out);
if (hist)
    hwrep(best);

It gives:

$ setopt correct 
$ dtea    
zsh: correct 'dtea' to 'date' [nyae]? y
lun. janv.  8 01:03:55 CET 2018  
$ alias  
dtea=date
$ dtea    
lun. janv.  8 01:07:42 CET 2018  
2 added 2 characters in body
source | link

You cancould base your code on the built-in alias defined here

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(wrong_value),
            createaliasnode(ztrdup(right_value), 0));

(not tested)

And add source ~/.zsh_correct_aliases to you .zshrc

You can base your code on the built-in alias defined here

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(wrong_value),
            createaliasnode(ztrdup(right_value), 0));

(not tested)

And add source ~/.zsh_correct_aliases to you .zshrc

You could base your code on the built-in alias defined here

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(wrong_value),
            createaliasnode(ztrdup(right_value), 0));

(not tested)

And add source ~/.zsh_correct_aliases to you .zshrc

    Post Undeleted by Tristan Gouge
    Post Deleted by Tristan Gouge
1
source | link

You can base your code on the built-in alias defined here

HashTable ht = aliastab;
ht->addnode(ht, ztrdup(wrong_value),
            createaliasnode(ztrdup(right_value), 0));

(not tested)

And add source ~/.zsh_correct_aliases to you .zshrc