jovanbulck / jsh

A basic UNIX shell implementation in C
GNU General Public License v3.0
30 stars 10 forks source link

Support bash-like alias syntax #63

Open GijsTimmers opened 9 years ago

GijsTimmers commented 9 years ago

The installer should check for files like:

.bashrc .zshrc .bash_aliases .zsh_aliases

If those files contain aliases, the installer should ask to put them in .jshrc. For example:

Non-default aliases found in .bashrc and .zshrc!
Do you want to import them?
<Yes>  No

(if the user presses YES here, go to the .jshrc editing dialog, which pops up somewhere in the installer anyway)

(The installer now shows the stuff that's inside .jshrc)

# ~/.jshrc : file containing jsh-shell commands executed by jsh on startup of a$
#
# Insert commands here to create your own custom jsh shell! :-)
# To get you started, see (https://github.com/jovanbulck/jo-shell/wiki/Sample-c$
# for more info and example configuration files

## Aliases found in .bashrc
alias ls='ls --color=auto'
alias ccat="pygmentize -g"
alias grep='grep --color=auto'
alias q='exit'

## Aliases found in .zshrc ##
alias sag='sudo apt-get'
alias ..='cd ..'
alias l='ls --color=auto'
jovanbulck commented 9 years ago

Yep this could be useful indeed. I have been thinking about this for a while.

I think the best option is to first support the bash/zsh style alias syntax

alias key='value with spaces'

instead of the - easier to parse - jsh style:

alias key "value with spaces"

Once that's done, users could have one single .shell_aliases file that is sourced from .bashrc as well as .zshrc as well as .jshrc. Such a scheme would be more flexible than 'just' importing aliases on jsh installation, as having all aliases in a central place allows editing them in a central place too.

Of course, once the syntax thing is implemented, with some sh script hacking, implementing your proposal shouldn't be to hard too.