i would like an alias that when i type
[Floodgate]~$: bash (pluginname)
in terminal it runs
[Floodgate]~$: . ~/bash\ plugins/(pluginname)
so far every alias i have tried has run
[Floodgate]~$: . ~/bash\ plugins/ (pluginname)
where the space between the slash and the (pluginname) is causing issues. it would be really nice to not have to make a new alias for every plugin but have one universal. so far the only thing that works is
alias bash='cd ~/bash\ plugins; .'
but that leaves me in
[Floodgate]~/bash plugins/$:
==================================================================================
thank you for all of your help! it was much appreciated
==================================================================================
As mentioned by Basile Starynkevitch above, the easiest way to accomplish this is to: (1) make sure the files in your ~/bash\\ plugins directory are executable by you (and they contain valid shell commands). eg
chmod 0755 ~/bash\ plugins/*
Then include ~/bash\\ plugins in your path. In your ~/.bashrc include:
export PATH=$PATH:~/bash\ plugins
Now to run your bash plugins, you can simply call them by name at the command prompt:
$ pluginname
There are many ways to do this. You can even create a function withing your .bashrc that takes the plugin names as an input and then executes the plugin, Eg inside .bashrc:
function exeplugins {
[[ -n $1 ]] || { echo "error: this command requires pluginname as input"; return 1; }
bash "~/bash plugin/${1}"
}
alias bplugin='exeplugins' # or any alias name you want 'bplugin' to be...
Now from the comman line you could simply do:
$ bplugin pluginname
Hope this helps. (+1 don't make an alias named 'bash' - bad juju follows)
I highly recommend not to name the alias "bash" since this is the command for opening a new bash and it can cause you problems with other applications or scripts. Otherwise this should work:
alias openplugin="cd ~/bash\ plugins && cd"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.