Jump to content

alexcory

Member
  • Posts

    47
  • Joined

  • Last visited

Everything posted by alexcory

  1. You could maybe add a setting called "text expansion key" so people could use other keys too. I just think tab is super intuitive and it allows it so your snippets don't interfere with other text you might be typing. Some people may prefer the enter key. Anyway, I will promote the shit out of the text expansion for Alfred if you add this one feature. Until then I'll have to stick with aText
  2. Basically what I want is instead of "auto expanding" what would be nice is to type your keyword, and then hit tab to expand it. Example: (you type) lorem + TAB which would equate to Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
  3. Okay, so I thought this through a little more and here's what I've gotten so far. I need to be able to grab the file path of the current project that I have open. I thought of a couple different ways to do this. First of all, at least for me, I only have 2 `workspaces` I used to house all of my projects on my machine. `htdocs` and `git repositories`. I'm assuming most developers do the same. With this in mind, I feel like developers could set their project directories initially which would give me the place to stop when pattern matching in the next step. I could then use Applescript to grab the current file, match that absolute path with the `projects` in their `workspace` to determine the `current project's directory`. I've found the following Applescript code from another workflow but being that I'm mostly `php` proficient, I am having trouble passing the output of the Applescript to php. I know there is a way to just grab the current project directory via Applescript but I can't figure out how. Could I get a wee bit of help on this please! Also, here are the steps I've thought of to complete this workflow. Any suggestions / advice on things I might have planned out wrong? Step 1 (aka: pre-search - initialized by hot key) Settings:Choose whether you want absolute path, or relative path to be default when pasting path in [need help figuring this part out] ie: relative get path of project directory [i feel like there's a better a better way to do this. Any way to do it in bash?]path to find: /users/username/path/to/workspace/current_project ideas:have the user initially set their "workspaces" where they usually put their projects (not preferred) grab the path via Applescript for whatever IDE/Text Editor the user is currently in [how do I grab this?] get path of current filepath to find: /users/username/path/to/workspace/current_project/views/elements/header.php possible logic // filename: get_path.scpt on getPath() -- get path to frontmost document set frontPath to (path to frontmost application as text) try tell application (frontPath) try set p to (path of document 1) -- preview uses this style on error set p to (do shell script "ruby -rcgi -e 'print CGI.unescape ARGV[0][7..-1]' " & quoted form of p) if p starts with "localhost" then set p to (file of document 1) -- keynote, pages uses this style end try end tell set p to POSIX path of p on error -- if all else fails try to get it through system events tell application "System Events" set theprocess to the first process whose frontmost is true set thewindow to the value of attribute "AXFocusedWindow" of theprocess set thefile to the value of attribute "AXDocument" of thewindow as string end tell --tell application "System Events" to tell (process 1 where frontmost is true) -- value of attribute "AXDocument" of window 1 --end tell set p to result set p to (do shell script "ruby -rcgi -e 'print CGI.unescape ARGV[0][9..-1]' " & quoted form of p) end if end try return p end getPath set p to getPath() of pathscript -- get parent directory do shell script "dirname " & quoted form of p return p [What am I doing wrong here?] // then grabbing the the output of p in the php file // filename controller.php <?php include_once 'get_path.scpt'; include_once 'Workflows.php'; $w = new Workflows; $path = exec('osascript get_path.scpt'); // [Why do neither of these work? Output: "Parse error: parse error in Command line code on line 1"] // $path = passthru("/usr/bin/osascript get_path.scpt"); var_dump($path); ?> Step 2 (aka: search) set the search location to current project's directory get path of queried fileie: /users/username/path/to/workspace/current_project/assets/css/main.cs set paths relative to current project (queried file & current file) ie: remove the "/users/username/path/to/workspace/ where the current_project names match, stop removing pre-directories // aka left with: $current_file = '/current_project/views/elements/header.php'; $queried_file = '/current_project/assets/css/main.css'; generate path to be pasted inpossible logic // find how many "../'s" are needed // find the path moving out $dotdot_slashes = count(explode('/', $current_file)) - 1; //don't move up passed current_project $path_out = str_repeat('../', $dotdot_slashes); // find the path moving mack in $remove_root_from_queried_file = array_shift(explode('/', $queried_file)); $path_in = implode('/', $remove_root_from_queried_file); // path to be pasted in $final_path = $path_out . '/' . $path_in; return $final_pathAny help would be greatly appreciated!
  4. So I'm trying to build a workflow where you would initially set whether you wanted to use the absolute path or relative path. It would then recognize the file you are currently in based off of where you're cursor is (shouldn't matter what IDE you're in), also recognize the project directory that is open. You would then be able to fuzzy search (or just regular search) the current project directory for a file you want to include in your current file (ie: a CSS file or something). When you hit enter, it would then either paste in the relative path or absolute path depending on what your initially set up. Any help oh how to start this?
  5. Awesome, I just tried this and I guess some other app is overriding the ⌥+C command. I know this doesn't pertain to you guys, but any advice on how to find out what's causing this? Maybe like some sort of global "key conflicts" or just away to see which apps are controlling which hotkeys? I really appreciate the help by the way!
  6. I can't find out which workflow is using ⌥+C. Any workflows to search through the hotkeys that are currently being used? I tried using the Help workflow but I'm not able to search through the created 'alfred-help.md' file. It's only showing a preview of the file and I wasn't able to locate where the file is at on my machine.
  7. `git` is in both `usr/local/bin` and `usr/bin/`. The same thing goes for `rsync`. At least I was able to see both of them in both directories. Could you walk through what's going on in those commands? Does the " --git-dir " portion return the git repository that you're currently selecting? What does the " --work-tree do? How does the ".git" work? The .git part is mostly what's throwing me off I think. // Add all the files $command = "git --git-dir $github/.git --work-tree $github/ add $github/*"; exec($command);
  8. Hey Andrew! I really appreciate the help! Here's what I've tried: turning off the `⌘-Click Opens Filename/URL` setting in iTerm to see if that might help. You don't think symlinks would have anything do with this do you? (Just curious). I had to reinstall Alfred when I reformatted my computer a couple weeks back. (Should I try reinstalling it again?) ​There's been some other problems but I pretty much have them all figured out. I just haven't had time to figure this one out lately. Help would be greatly appreciated! -Alex (btw, favorite app on my mac. I customized my mac to have the Ubuntu Ambience theme and made Alfred look like Sublime Text's ⌘+⇧+P . see here if you're curoius!)
  9. Whenever I go to open a URL, it opens the default terminal (iTerm) instead of opening the url. I think I figured out what the problem is though. (partially) I noticed there were two chrome images on the drop-down as you can see from this image. Any idea on what might be causing this/how to fix it?
  10. I can't seem to get the php to execute the command I'm giving it in the terminal. The Problem: 1. Won't actually perform the task in iTerm 2. My plugins don't open at vim startup if I start vim like this vim ~/path/to/directory But will work with this cd ~/path/to/directory; vim Here's what I put in php: $dir = "{query}"; $cmd = "cd " . "$dir" . "; vim"; //echo $cmd; //ouputs: cd path/to/proper/directory; vim; exec("$cmd"); // doesn't even open the terminal $dir = "{query}"; $cmd = "open -a iTerm; cd" . "$dir" . "; vim;"; // IF TERMINAL SWITCH THE ABOVE iTerm TO Terminal //echo $cmd; //ouputs: cd path/to/proper/directory; vim; exec("$cmd"); // doesn't even open the terminal Then I tried running a `terminal command` action with the following in it query=“{query}”; echo “${query// /\\ }" // because the ~/path/to/foo bar won't work. Needs to be ~/path/to/foo\ bar I know that last one is not quite right. I'm still learning bash. I posted a question on StackOverflow here. Can anybody help me please!?
  11. I'm pretty sure it's not a good idea to put cd in there but it made it work properly without opening the terminal every time. It ended up looking like this. # -- Step 1: Sync Local Directories -- rsync -avz /path/to/directory1/ ~/path/to/local/git\ repository/for/directory1/; # rm -r .DS_Store; # -- Step 2: Push Changes To Github -- cd ~/path/to/local/git\ repository/for/directory1/; git add *; git commit -m "{query}"; git push --all Is it not good practice to put the cd in there? Can it cause problems or anything?
  12. Why does this work in if I put it in a Terminal Command but not in a Run Script set to /bin/bash/? # -- Step 1: Sync Local Directories -- rsync -avz /path/to/directory1/ ~/path/to/local/git\ repository/for/directory1/; # rm -r .DS_Store; # -- Step 2: Push Changes To Github -- ~/path/to/local/git\ repository/for/directory1/; git add *; git commit -m "{query}"; git push --all
  13. Could you maybe help me understand a little how this is working. I'm kind of new to bash and really new to XML (except for HTML ha). I know some basics but some of these options are confusing me. - - - - - - - - - demo1: Script Filter - - - - - - - - - - cat << CODE // Is this just taking what is typed into alfred and displaying it? What do <?xml version="1.0"?> // the << do? I know in bash, cat means to just display contents of a file <items> // does it work the same way here? <item uid="demo" arg="{query}" valid="yes"> <title>First Name</title> <subtitle>Enter your first name</subtitle> <icon>icon.png</icon> </item> </items> CODE // How does CODE work? - - - - - - - - - demo1: Run Script - - - - - - - - - - if [ -f "saved.txt" ]; then // What does -f do? rm saved.txt fi in=$(echo "{query}" | tr -d "\\") // How does this work? // What does | tr -d "\\" do/mean? echo "$in" > saved.txt // Where is saved.txt located in the file structure? - - - - - - - - - demo2: Run Script - - - - - - - - - - data=$(cat saved.txt) echo "$data {query}" // Why do we need {query} after $data? I'm confused here. rm saved.txt
  14. How do I put that into my php? ie: $bundle_id = "defaults read " . $plist_subdir . "/info.plist" . '" bundleid"';
  15. Could anyone tell me why this doesn't work? <?php require_once('workflows.php'); $w = new Workflows; # Navigate to data directory $data_dir = $w->home() . '/Library/Application\ Support/Alfred\ 2/Workflow\ Data'; # lists all the files inside the data directory $data_dir = glob("$data_dir" . '/*'); # grab bundle id from project folder $plist_dir = $query . "/info.plist"; $info_plist = simplexml_load_file( $plist_dir ); $bundle_id = $info_plist->dict->string; // # Grab the data sub-directory's name to compare to the bundle id foreach ($data_dir as $data_subdir) { // grab the end of the file path (the name of bundle_id) $data_subdir = basename($data_subdir).PHP_EOL // if name of data directory matches the bundle_id if ($data_subdir === $bundle_id) { // then open the data directory in Finder $cmd = 'open -a Finder "$data_dir"'; exec("$cmd"); } }
  16. Here's a better formatted question http://stackoverflow.com/questions/22289704/how-to-retrieve-data-from-info-plist-xml-document-and-store-into-a-php-array
  17. Okay so basically I'm trying to make a workflow that helps people quickly reference the alfred workflow directories super easily. I made one partially already but now I'm trying to go a little further. I guess I'm extending the Manage Alfred Extension. What I am trying to accomplish is instead of hitting function to toggle a workflow on or off, I want to simply open the data directory in finder. Is there an easier way to grab the individual data paths? ie: {data} kind of like {query} but it would output the data directory instead of the project folder directory. I posted this to stack overflow to try and get some help. Thanks for any help you can give!
  18. Alfred Workflow Builder QuickRef (Download Here) (Github) (Packal) Description Helps locate the files and folders that you most often need to access for building Alfred workflows by listing the files in the order which workflows or data directories you most recently used. This workflow was based of a previous workflow built by Dajun Duan. His workflow can be located here. Controls Enter — Browse in Alfred ⌘ Enter — Reveal in Finder ⌥ Enter — Open in Sublime Text Type in awf and choose. Data Directories Workflows Directory
  19. Okay so I've been working on this workflow but I was wondering If I we could do a Google Hangout or Skype or something really briefly. If not, no worries. I'm just used to web development with PHP so it's harder diving into this. Basically with Web Dev, I'm able to output stuff to the screen to see if I'm doing things correctly. Ie: I say <?php echo "hello world!" ?> , refresh the page, and then I see hello world. What I was going to check was to test it out, say... <?php echo $w->path(); ?> to see if it would return the path. But I don't know were to see the output. Do you see what I'm saying? Also, with the exec() command. Do I just put per say.. a bash script inside it? ie: $data_directory = "path/to/data_directory/"; # Make sure the data directory exists // if the directory doesn't exist if ( !file_exists( $data_directory ) && !is_dir( $data_directory ) ) { // Make a new directory exec( 'cd path/to/; mkdir data_directory/;' ); exit; }
  20. Okay so I have this idea that I got from Nettuts+. It's already a Sublime Text Package. Here is a Demo of it. 1. I basically want to be able to look up my gists the same way I can with willfarrell's Github Workflow using my username and using a personal access token from github. 2. I want to be able to filter out all the gists that don't have the #snippet tag at the end of them. 3. Once I search and find the correct one, I want it to copy it to my clipboard and also paste the gist snippet whatever text editor/IDE/application my cursor is currently in. Could anyone give me any advice on how to start this project? I really really want to learn and get better at making Alfred workflows so I think this would be a great little project! I have some experience in PHP, Javascript/jQuery, HTML/CSS, and some with AppleScript but I wouldn't consider myself a heavy hitter in any just yet but I will learn what I need to. I just need guidance. Thanks for any advice!!
×
×
  • Create New...