alias to trigger script sh that needs to execute

169 Views Asked by At

Beginner here, Have been reading and trying lots of ideas just kind of frustrated now.

learning about alias and bash functions

It all begins because I am trying to learn swift came up with an error last week that put me in a tailspin for hours. But wound up finding out about dumping derived data other fixes to clear cache along with a clean and build. Why not do them all in one swoop.

so after having to do this I was like there has to be a way to do this with an exe function. I am on a macBook pro with el cap

then i came across alias. And a whole new beast has emerged. Somewhere read to create aliases.sh and point bash_profile to there. so I have done that. I get the basics going. and tried to put this into a function in the aliases.sh but that didn't work. so I was trying to create a different .sh and trigger it from aliases.sh. terminal didn't like that. kept coming back with errors and the only way I could get rid of them was delete them and start over from scratch. Have done this a few times.

That is the description here is what i have and am trying to do.

'nano ~/.bash_profile
it opens and i type in there: source /Users/xx/.aliases.sh   # General aliases
control o + enter
nano ~/.aliases.sh
it opens and in there I add basics that i have found looking around
alias ls="ls -CF"  # Column and file ext
alias ..="cd .."   # back up quicker      ****you get the idea****

alias xc="/Users/xx/.xcodeReset.sh"'

all went well until i put in that last line. and the bash problems that came with it. this is what i have inside of xcodeClean.sh. had to put photo. couldn't figure our way to copy paste without a huge mess.

xcodeReset.sh /br

so i have tried taking out the bin/bash from the .sh, tried putting the bash in front of /users/, but as you probably know anytime I run Terminal I have error from the start. And anything I did I could not get past them. Only way I could get back to a clean new terminal look was to delete both xcodeReset and aliases and start over. now I can just keep on copy and pasting from my notepad that code. But I know there is a way around this little devil. I found this cleaner for xCode around here and other forums. I'm just trying to get it to run with a simple alias.

I am pretty green here and tackling something that I know is possible. If you have any help I would appreciate it. Too many nights all night digging for the answer.

1

There are 1 best solutions below

3
Dale_Reagan On
  1. Read the man page for Bash on your system - it should describe the 'startup sequence' as well as which files to use for aliases, etc.

  2. in a 'tmp' file, create the aliases that you wish to 'test', and once done,

  3. you can simulate how your login will work with these aliases by using the 'source' command, i.e.
    source ~/your_test_file

  4. After running the 'source' command, all of the aliases should be available for use/testing - until you logout (or otherwise re-initialize your login environment...)

  5. After all is well with 'source' testing, then copy your testfile into your desired ~/*.rc file (i.e. `/.bashrc')

  6. now 'test for real' (logout and log back in - all working?)

:)
Dale