[{"data":1,"prerenderedAt":456},["ShallowReactive",2],{"Categories":3,"NavIndexCategoriesCountFooter":203,"content-\u002F2011\u002F04\u002F02\u002Fbash-helper-function-for-rvm-gemsets\u002F":204},[4,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,68,70,71,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,139,140,141,142,143,144,145,146,147,148,149,150,151,152,153,154,155,156,157,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202],{"category":5},"System Administration",{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},"Software Development",{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":27},{"category":27},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":5},{"category":27},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":27},{"category":27},{"category":67},"Drones & RC",{"category":69},"DIY Projects",{"category":67},{"category":72},"Photography",{"category":69},{"category":69},{"category":69},{"category":67},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":69},{"category":67},{"category":69},{"category":69},{"category":67},{"category":67},{"category":72},{"category":72},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":5},{"category":5},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":5},{"category":67},{"category":67},{"category":72},{"category":72},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":67},{"category":72},{"category":67},{"category":138},"3D Printing - Laser Cutting - CNC",{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":138},{"category":5},{"category":138},{"category":27},{"category":27},{"category":138},{"category":138},{"category":72},{"category":158},"Photography,3D Printing - Laser Cutting - CNC",{"category":27},{"category":27},{"category":69},{"category":27},{"category":27},{"category":27},{"category":27},{"category":5},{"category":67},{"category":5},{"category":5},{"category":27},{"category":27},{"category":27},{"category":27},{"category":27},{"category":69},{"category":27},{"category":27},{"category":27},{"category":27},{"category":181},"Home Assistant",{"category":181},{"category":72},{"category":27},{"category":27},{"category":72},{"category":138},{"category":5},{"category":72},{"category":72},{"category":138},{"category":27},{"category":181},{"category":181},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},{"category":72},191,{"id":205,"title":206,"body":207,"category":444,"date":445,"description":213,"embedImage":444,"extension":446,"image":444,"intro":444,"meta":447,"navigation":290,"path":448,"seo":449,"series":444,"sitemap":450,"stem":451,"tags":452,"__hash__":455},"content\u002F2011\u002F04\u002F02\u002Fbash-helper-function-for-rvm-gemsets.md","bash helper function for rvm gemsets",{"type":208,"value":209,"toc":442},"minimark",[210,214,217,220,223,226,438],[211,212,213],"p",{},"By convention I use an rvm gemset per project - named after the directory that the project lives in.",[211,215,216],{},"For example src\u002Frails\u002Ffoo would have gemset foo",[211,218,219],{},"Since I switch a lot between machines - I always end up having to go check if the gemset exists and create it if not.",[211,221,222],{},"A small bash function (dump it in .bash_profile) and then when in the projects home dir you can just run rvmgo (or if you want a different ruby then e.g. rvmgo 1.8.7) and it will switch to the correct version\u002Fgemset creating the gemset if needed.",[211,224,225],{},"Note - it will not install a missing ruby.",[227,228,233],"pre",{"className":229,"code":230,"language":231,"meta":232,"style":232},"language-ruby shiki shiki-themes github-dark","function rvmgo {\n    ver=1.9.2\n    ver=${1-$ver}\n\n    pwd=${PWD##*\u002F}\n\n    rvm $ver\n    if [ $? == 0 ]; then\n        # rvm to a non existing version will set $? to 1. However rvm to a non existing gemset in an existing version\n        # returns 0 and an onscreen error - so we need to check for the gemset another way\n        rvm $ver@$pwd\n        gemdir=`rvm gemset dir`\n        if grep -q $pwd \u003C\u003C\u003C$gemdir; then\n            echo \"Changed to $ver@$pwd\"\n        else\n            rvm gemset create $pwd\n            rvm $ver@$pwd\n        fi\n    fi\n}\n","ruby","",[234,235,236,245,266,285,292,309,314,320,341,347,353,359,371,393,402,408,414,420,426,432],"code",{"__ignoreMap":232},[237,238,241],"span",{"class":239,"line":240},"line",1,[237,242,244],{"class":243},"s95oV","function rvmgo {\n",[237,246,248,252,256,260,263],{"class":239,"line":247},2,[237,249,251],{"class":250},"s9osk","    ver",[237,253,255],{"class":254},"snl16","=",[237,257,259],{"class":258},"sDLfK","1.9",[237,261,262],{"class":243},".",[237,264,265],{"class":258},"2\n",[237,267,269,271,273,276,279,282],{"class":239,"line":268},3,[237,270,251],{"class":250},[237,272,255],{"class":254},[237,274,275],{"class":243},"${",[237,277,278],{"class":258},"1",[237,280,281],{"class":254},"-",[237,283,284],{"class":243},"$ver}\n",[237,286,288],{"class":239,"line":287},4,[237,289,291],{"emptyLinePlaceholder":290},true,"\n",[237,293,295,298,300,302,305],{"class":239,"line":294},5,[237,296,297],{"class":250},"    pwd",[237,299,255],{"class":254},[237,301,275],{"class":243},[237,303,304],{"class":258},"PWD",[237,306,308],{"class":307},"sAwPA","##*\u002F}\n",[237,310,312],{"class":239,"line":311},6,[237,313,291],{"emptyLinePlaceholder":290},[237,315,317],{"class":239,"line":316},7,[237,318,319],{"class":243},"    rvm $ver\n",[237,321,323,326,329,332,335,338],{"class":239,"line":322},8,[237,324,325],{"class":254},"    if",[237,327,328],{"class":243}," [ $? ",[237,330,331],{"class":254},"==",[237,333,334],{"class":258}," 0",[237,336,337],{"class":243}," ]; ",[237,339,340],{"class":254},"then\n",[237,342,344],{"class":239,"line":343},9,[237,345,346],{"class":307},"        # rvm to a non existing version will set $? to 1. However rvm to a non existing gemset in an existing version\n",[237,348,350],{"class":239,"line":349},10,[237,351,352],{"class":307},"        # returns 0 and an onscreen error - so we need to check for the gemset another way\n",[237,354,356],{"class":239,"line":355},11,[237,357,358],{"class":243},"        rvm $ver@$pwd\n",[237,360,362,365,367],{"class":239,"line":361},12,[237,363,364],{"class":250},"        gemdir",[237,366,255],{"class":254},[237,368,370],{"class":369},"sU2Wk","`rvm gemset dir`\n",[237,372,374,377,380,382,385,388,391],{"class":239,"line":373},13,[237,375,376],{"class":254},"        if",[237,378,379],{"class":243}," grep ",[237,381,281],{"class":254},[237,383,384],{"class":243},"q $pwd ",[237,386,387],{"class":254},"\u003C\u003C\u003C",[237,389,390],{"class":243},"$gemdir; ",[237,392,340],{"class":254},[237,394,396,399],{"class":239,"line":395},14,[237,397,398],{"class":243},"            echo ",[237,400,401],{"class":369},"\"Changed to $ver@$pwd\"\n",[237,403,405],{"class":239,"line":404},15,[237,406,407],{"class":254},"        else\n",[237,409,411],{"class":239,"line":410},16,[237,412,413],{"class":243},"            rvm gemset create $pwd\n",[237,415,417],{"class":239,"line":416},17,[237,418,419],{"class":243},"            rvm $ver@$pwd\n",[237,421,423],{"class":239,"line":422},18,[237,424,425],{"class":243},"        fi\n",[237,427,429],{"class":239,"line":428},19,[237,430,431],{"class":243},"    fi\n",[237,433,435],{"class":239,"line":434},20,[237,436,437],{"class":243},"}\n",[439,440,441],"style",{},"html pre.shiki code .s95oV, html code.shiki .s95oV{--shiki-default:#E1E4E8}html pre.shiki code .s9osk, html code.shiki .s9osk{--shiki-default:#FFAB70}html pre.shiki code .snl16, html code.shiki .snl16{--shiki-default:#F97583}html pre.shiki code .sDLfK, html code.shiki .sDLfK{--shiki-default:#79B8FF}html pre.shiki code .sAwPA, html code.shiki .sAwPA{--shiki-default:#6A737D}html pre.shiki code .sU2Wk, html code.shiki .sU2Wk{--shiki-default:#9ECBFF}html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":232,"searchDepth":247,"depth":247,"links":443},[],null,"2011-04-02 11:23:20 +0200","md",{},"\u002F2011\u002F04\u002F02\u002Fbash-helper-function-for-rvm-gemsets",{"title":206,"description":213},{"loc":448},"2011\u002F04\u002F02\u002Fbash-helper-function-for-rvm-gemsets",[231,453,454],"rvm","bash","4S_7x3hzl0qZ8NqFsFkH52jihcsj9o2Jyq0Uur6W2rE",1775293013718]