0

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.

iSpeedyG
  • 1
  • 3

1 Answers1

0
  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

Dale_Reagan
  • 1,953
  • 14
  • 11
  • For the most part I can run bash on my system. I am not digging that deep yet. But git has me trying a lot of new things. Source testing has happened in my 1st post. Trying to get that xcodereseter running. As far as I can tell El cap. loads up bash as soon as I open terminal. I am mainly just wanting a quick to key press and enter and triggers the shutting down of Xcode, clearing cache, dumping derived data and rebooting. I am just having an issue because of sheBang. I pull it out and cannot get the script to run on its own. I put it back in I have errors popping up everywhere. – iSpeedyG Oct 16 '15 at 11:57
  • Hmm, this sounds 'different' than the original query; make sure that you don't have 'special codes' in your file, i.e. cat -ve yourfile (see 'man cat' for your system; if you see any '^' codes those ('^M' == '\r' on my system) will hose your script... – Dale_Reagan Oct 16 '15 at 21:29
  • Just re-sponding to get this question back on the stack. Maybe somebody new will see it and can give me that one line that I can research to make this script work as an alias. – iSpeedyG Oct 28 '15 at 16:15