Jump to content

Search the Community

Showing results for tags 'bash'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • Alfred 3
  • Make the Most of Alfred
    • Discussion & Help
    • Bug Reports
    • Alfred Feature Suggestions
    • Themes
  • Alfred Workflows
    • Share your Workflows
    • Workflow Help & Questions
  • Alfred v2 Themes
  • Alfred Remote for iOS
    • Alfred Remote Discussion & Help
    • Remote Connection Troubleshooting

Categories

  • Articles
    • Forum Integration
    • Frontpage
  • Pages
  • Miscellaneous
    • Databases
    • Templates
    • Media

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Twitter


Website URL


Jabber


Location


Interests

Found 52 results

  1. Currently there are some issues with Run Script when using /usr/bin/php, /usr/bin/perl, /usr/bin/python, etc... Those processes are launched from the shell using certain environment variables (such as LANG=C or another non-unicode supporting environment) which disable features or environments we may need to run our scripts correctly. Currently the only solution to this would be to use /bin/bash or /bin/zsh and set things ourselves and then launch our script from there. Doing so means we sacrifice the convenience of having scripts right in the workflow visual themselves AND we can no longer take in the query conveniently. We must now take in the query through bash for example, which is quite tricky (an experienced programmer may be ok, but just try taking in something like She said, "He said, 'this is fantastic!' ", and you'll see things are much worse than what is apparent). To save us from this mess, we could have a vertical dual pane Run Script, where the top pane is a bash or zsh, and the bottom one of the script languages. Users can then easily set any setup variables they need to make things run smoothly. Thanks kindly, Matthew
  2. I'm trying to modify the AppendText2File workflow so that if the text to be appended has a single quote inside it the workflow doesn't break. Here's the relevant portion of the workflow: dt=`date` ## append to the original file echo "* "$dt" -- "{query} >> $original What do I do to strip out single quotes (or replace them with something bash/Alfred doesn't hate)?
  3. I would like to write an Alfred workflow that acts as a thin wrapper around a command line application which takes many option flags and arguments. Is there any way to integrate Alfred with the bash completion script of this application in such a way that the possible completions of a partially entered command are displayed?
  4. Hi All, I want to fire off MacVim with a keyword action and a shortcut for where to open MacVim, e.g.: mvim d -> open MacVim in the folder ~/Downloads mvim h -> open MacVim in the folder ~/ ... I wrote a case statement in bash like this: MVIM=/usr/local/bin/mvim case "{query}" in "h") cd ~/ && $MVIM ;; "d") cd ~/Downloads && $MVIM ;; *) echo "unknown directory specified" ;; esac And when I run (e.g., mvim d) it once works flawlessly. However, if I want to open a second window of MacVim by running e.g. 'mvim h' nothing happens until I close the first window. It feels like the calls are queued (or mvim is not detached from the shell and keeps the workflow open and blocks it). Is this by design or could somebody give me a hint how to work around this? Thanks in advance, jochen
  5. Hey everyone, here's one I can absolutely not figure out for myself: if have this very simple bash script called launcher.sh #!/bin/bash node="/usr/local/bin/node" ${node} test.js 127.0.0.1:8374 &> node-out.txt & and a quite simple node script called test.js require('easyimage').thumbnail({ src:"a.jpg", dst:"b.jpg", width:60, height:60 }).then( function(image) { console.log('success'); }, function (err) { console.log(err); }); If i call from the terminal node test.js or ./launcher.sh, then everything is fine (I get image a.jpg to be cropped and written to b.jpg), but if i trigger it through a script filter containing only ./launcher.sh, then i get this error: [Error: File not supported.] and I have tried with another less used npm package for test.js: var resizeCrop = require('resize-crop'); resizeCrop({ format: 'jpg', src: "a.jpg", dest: "b.jpg", height: 60, width: 60, gravity: "center" }, function(err, filePath){ if(err) console.log(err); else console.log("success"); } ); which throws a more verbose error when triggered from a script filter: events.js:72 throw er; // Unhandled 'error' event ^ Error: spawn ENOENT at errnoException (child_process.js:1001:11) at Process.ChildProcess._handle.onexit (child_process.js:792:34) Do you guys have any idea why it works from the terminal but not from alfred? On my real script, I'm writing/reading other files and i never have any issues with it...
  6. Hi all, I'm sure there's an easy answer to this, but could someone explain to me why a simple Keyword to Script workflow, consisting of a keyword foo and the following one-line bash script (where mate is the TextMate shell utility and bar is the absolute path to a text file) sudo mate bar does absolutely nothing, even though it works fine when I run it in Terminal,. This workflow used to work, but it hasn't for the past couple of months (I think, because I don't use it very often). It's not a huge deal, but I'd like to understand what's broken it. It's not because it's run with sudo, because mate bar does nothing (where bar is in my home directory in this case), and neither is it a problem with mate, because vi bar doesn't work either. All my other Keyword to Script workflows are working fine, including a test one I just created with rm bar as the script. Any ideas as to why I can't invoke text editors in workflows? Thanks! fort
  7. I have a need to have this snippet in my bash workflow: osascript <<EOT set myString to "This\\ is\\ string" return myString EOT It breaks with error: [ERROR: alfred.workflow.action.script] Code 1: 22:23: syntax error: Expected “"” but found unknown token. (-2741) I would like the output string to look like "This\ is\ string".
  8. Hi guys, I made BASH framework for Alfred that makes it easy to create a certain kind of workflow that allows you search and look up information without leaving the Alfred interface. It basically allows you to display results after selecting a result. It's a way around the fact that "Script Filters are the only way to pass feedback to Alfred" Here is an example. The magic happens at step 3. 1. Type in workflow keyword: 2. Type query to find results: 3. Selection of a result brings up additional results. There are two options for workflow creation: static, which is similar to just manually creating a CSV file and requires no coding. Example "code." dynamic, which has a library that you can use similarly to static or to display dynamic data. Example code. I believe I've documented it pretty well in the README, but if there are any questions about how to use it I am glad to help. Some example applications: - "define" command that doesn't have to open the Dictionary - Synonym/Antonym retriever - Contact lookup without opening Contacts - Any sort of general reference (e.g. recipes or brewing instructions) Here is the github page: http://bit.ly/alfred-arf
  9. A simple workflow for managing casks. Download — stable version. The source code is available here: https://github.com/pstadler/alfred-cask
  10. Hi all, I've have some problems with determining the locals language in bash script in workflows in Alfred2. I'm on OSX 10.7.5 FR. My script : DATE=$(echo "{query}" | sed -e's/HAEC/CEST/g' -e's/HNEC/CET/g'); export LC_TIME="fr_FR.UTF-8"; date -jf "%d %B %Y %T %Z" "$DATE" "+%Y%m%d%H%M%S" I use it : Select a text date (i.e. : "18 décembre 2006 19:24:12 HNEC"), use my hotkey to launch Alfred2/Workflow/Bashscript Problem : Works • In Alfred2 when month has NO accented character (i.e. : "18 janvier 2006 19:24:12 HNEC") • In terminal as is with or without month with accented characters Does NOT work • In Alfred2 when month has accented character Note : I had to add 'export LC_TIME="fr_FR.UTF-8"' as I assume Alfred bash script works in EN. It didn't work with french dates even though my whole system is in french and it DOES work in terminal without the export command. Also, I had to "translate" HAEC and HNEC as date command doesn't understand this frenchified CEST and CET. Any ideas on how I can bypass this problem ? Is it a bug ? Thanks in advance ! Hubert
  11. Hi guys, I made a workflow that checks to see if a specified website is online or offline. It uses the website "isup.me". The default trigger is "isd <URL>" Here's the github page: https://github.com/cheniel/Alfred-Site-Checker If you're just looking for the good stuff (immediate download): http://bit.ly/1evjqSu It's my first workflow, would definitely appreciate any comments or suggestions. Edit 4/10/14: fixed missing temporary folder bug.
  12. Hi Guys, I am having an issue with the following bash script: cd /Volumes/Development/RAGUSOURCE/highlander IFS=', ' read -a args <<< '{query}' case ${args[0]} in status) echo `vagrant status` ;; up) echo `vagrant up` ;; *) echo 'Usage highlander {status|up|halt|ssh}' exit 1 ;; esac The commands run fine via the terminal, but not in a workflow.
  13. My goal for my workflow is to run a bash command that uses ldapsearch to search my university's directory and return a list of contacts that operates similar to Alfred's contact search. I've got my bash script running fine, but I'm just unclear on how to format the returned information in the best way. Any guidance on script filtering and bash script returning would be great! I am relatively new at this, so excuse my poor terminology.
  14. Hi all! So I'm finally getting around to doing my very own workflow programming and I've run into some weirdness creating a Workflow that Runs a Bash Script in Alfred v2. I've tested this bash script on the command line and it works a treat. In fact, most of the workflow works in Alfred but a couple of things are funky: When using \n inside my echo commands it literally prints \n instead of using a new line. I'd like to format my virtual hosts files as I have them now. It's even more critical for /etc/hosts where that needs to on a new line. When running the mysql logic - It doesn't create the database. It will, however, start MySQL which is something. Note I have tried to both make the commands sequential and used the && distinction. Neither works. The long and short of this is that basically I am creating a new local site on my stack. I create a directory, a virtual host entry, an /etc/hosts entry, and a MySQL database. Simple enough. I am sure this is due to my being very new to Alfred workflows. Probably something silly. Any help you can offer would be appreciated greatly. Interpreter is /bin/bash - All of the escapes are checked in the workflow window (Backslashes, Brackets, etc.) and the whole script looks like this... site="{query}" # Create a new directory mkdir ~/Sites/$site # Create a new entry in the Apache virtual hosts file. echo "\n<VirtualHost *:80>" >> ~/Sites/httpd-vhosts.conf echo " ServerName $site.localhost" >> ~/Sites/httpd-vhosts.conf echo " DocumentRoot \"/Users/ksilanskas/Sites/$site\"" >> ~/Sites/httpd-vhosts.conf echo " ErrorLog \"/Users/ksilanskas/Sites/Logs/$site-errors.log\"" >> ~/Sites/httpd-vhosts.conf echo "</VirtualHost>" >> ~/Sites/httpd-vhosts.conf # Ensure MySQL is running and then create the database. mysql.server start >> /dev/null && echo "CREATE DATABASE $site" | mysql -u root -proot >> /dev/null # Add an entry to the /etc/hosts file and restart Apache osascript -e "do shell script \"sudo echo '127.0.0.1 $site.localhost' >> /etc/hosts && sudo apachectl restart >/dev/null\" with administrator privileges" Thanks again! P.S. To prove I did a little searching... I did find this but it didn't look like a complete topic... http://www.alfredforum.com/topic/879-create-mysql-database-from-script-action/?hl=mysql - I'd prefer to just stick with using command line on this one if possible.
  15. Helps you lookup what shell commands mean using http://explainshell.com. Your OS X installation should have PHP 5.3.3 or newer installed. Lion or Mountain Lion should meet the minimum requirements. If not, you can install the latest version of PHP with MacPorts or Homebrew. Download! Requires Alfred 2 and the Powerpack. Updates can be found and installed using Monkey Patch, or the older Alleyoop (discontinued).
  16. A workflow for managing processes with top and kill. Use top to display the most active processes and kill to find and kill any running process by its PID or Name. Download — stable version. The source code is available here: https://github.com/pstadler/alfred-top
  17. I am working on a workflow which should execute a shell script command for of the documents (*.xml files) currently selected in the Finder. I did some experiments around it, but could not get it to work yet. Any pointers, e.g. what workflow elements I will need? I am currently thinking along the lines of first calling an applescript which gives me the selected files, then filtering out only the xml files and lastly calling a shell script for each of the files or alternatively calling the script once but passing along an array of xml files. What do you guys think? Thanks for any suggestions / sample workflows.
  18. Hello, I hope my question is not yet asked somewhere else. So, I've just created a simple and straight forward workflow to make a folder tree. It works fine when interpreted in terminal, but in Alfred the tree is created into the workflow folder. I've seen here that the relative path is always the path trelative to the workflow folder. My question is probably noobish but… how can get the path of the folder I'm in at the time I launch Alfred to make my request ? Any hint would be appreciated.
  19. Hi folks, I manage to create the following script in php that's working. The aim is to extract and use multiple parameters from a single {query}. Here's a simplified example: $query = explode(' ', '{query}'); $elemA = $query[0]; $elemB = $query[1]; $elemC = $query[2]; echo "{$elemA}{$elemB}{$elemC}"; I would like to do the same in bash but cannot manage to get it work. Here's my try: This one is working outside Alfred, directly for my Terminal. Basically, it also automatically detect any space as a separator. query="{query}" i=1 for param in $query; do case $i in 1) elemA=$param;; 2) elemB=$param;; 3) elemC=$param;; esac i=$[i+1] done echo "${elemA}${elemB}${elemC}" From all my tries, I've not been able to enter the "for" loop statement… Would you have any idea? Thanks in advance, Cheers, Édouard.
  20. Here is a simple workflow to create a text file with clipboard content in the current or top most Finder window/folder: 1. using a hotkey: the text is created with the following filename pattern: Clipboard - yyymmdd(hhmmss).txt 2. you can use newf key in Alfred (see screenshot) so you can write the first part of the file name (use CTRL key to remove the date and time from the filename). The default date and time was code this way in order to always generate an unique filename. Screenshot: http://d.pr/i/A2Kv Download: http://d.pr/f/5Jp7 This workflow is more a sample on how to use Shell/Bash and AppleScript together. Credits to phyllisstein and his workflow* and David Ferguson for helping. * http://www.alfredforum.com/topic/394-fixed-create-a-new-file-in-the-finder/
  21. Bash scripts launched by Alfred in the context of workflows don't respect the OS X user's locale and instead default to the generic "C" locale. Alfred should use the same locale that is used when a user starts an interactive shell in Terminal.app (For instance, running locale in Terminal on my US-English system returns: LANG="en_US.UTF-8" LC_COLLATE="en_US.UTF-8" LC_CTYPE="en_US.UTF-8" LC_MESSAGES="en_US.UTF-8" LC_MONETARY="en_US.UTF-8" LC_NUMERIC="en_US.UTF-8" LC_TIME="en_US.UTF-8" LC_ALL= ) To verify the problem, use the following test workflow: download and install https://dl.dropboxusercontent.com/u/10047483/localetest.alfredworkflow type localetest into Alfred, which will display the effective locale in large type To work around the problem, use the following at the beginning of your script: export LANG="$(defaults read -g AppleLocale).UTF-8" Possibly related [update: NOT related - see below]: non-ANSI characters are currently encoded in unexpected ways: In normal UTF-8 encoding, "ü" should be passed in (via {query}) as the following multi-byte sequence: expected: 0xc3 0xbc instead, Alfred currently passes: 0x75 0xcc 0x88 - 3(!) bytes
  22. Not sure if this has already been done, but here's a simple workflow allowing you to open multiple VLC windows. Download: vlc-new-window.alfredworkflow
  23. Hey guys ! Let me explain the situation first : I work with people on windows but i work on OSX. I often get DOS path on a shared volumes (mounted with samba) where documents i need are stored. Usually, it's .png or other graphic files. And there we are, i want to do a workflow where i type a keyword then paste the DOS path i was given; then i run a bash script that translate the DOS path to Unix path (script i already have); finally i want that new path to be open in my browser. So far, i made the input with a "keyword" then the {query} sent to a "Run script" and the new {query} sent to a "Notification". It works that way but it's not what i want. I can't figure out how to send the new {query} to the browser though. Did i miss something ? Thanks for the help GoOz
  24. Hi all, I've have some problems with determining the locals language in bash script in workflows in Alfred2. I'm on OSX 10.7.5 FR. My script : DATE=$(echo "{query}" | sed -e's/HAEC/CEST/g' -e's/HNEC/CET/g'); export LC_TIME="fr_FR.UTF-8"; date -jf "%d %B %Y %T %Z" "$DATE" "+%Y%m%d%H%M%S" I use it : Select a text date (i.e. : "18 décembre 2006 19:24:12 HNEC"), use my hotkey to launch Alfred2/Workflow/Bashscript Problem : Works • In Alfred2 when month has NO accented character (i.e. : "18 janvier 2006 19:24:12 HNEC") • In terminal as is with or without month with accented characters Does NOT work • In Alfred2 when month has accented character Note : I had to add 'export LC_TIME="fr_FR.UTF-8"' as I assume Alfred bash script works in EN. It didn't work with french dates even though my whole system is in french and it DOES work in terminal without the export command. Also, I had to "translate" HAEC and HNEC as date command doesn't understand this frenchified CEST and CET. Any ideas on how I can bypass this problem ? Is it a bug ? Thanks in advance ! Hubert
  25. Bug reproduced at both home and work. Configs : @home: OSX: 10.7 Alfred: v2.0.1 build 173 @work: OSX: 10.6 Alfred: v2.0.1 build 173 Origin This topic Step to reproduce NB: I did a brand new workflow to be sure it was clean of any extra hidden space or carriage return. Basically it looks like this: A keyword object with arg to pass the {query} Run Script object uses /bin/bash and simply does an echo "foobar" Output 1 displays the {query} Output 2 displays display the text in the text field (e.g. foobar) Output 3 displays the {query} passed by the script. When i trigger the workflow with "foobar" as an argument, this is what i got : As you can see the {query} passed by the script has an extra space at the bottom. As harmless as it seems, it's not Can't properly use the {query} in a bash script because of this. Do you confirm?
×
×
  • Create New...