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

Categories

  • New Features
  • Other

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. Hi everybody! OK, I am desperate - I've spent the last two days trying to cobble together a tagging workflow and I am totally stuck... I would be extremely thankful if some of you Alfred-specialists around here could take a look at my issue. I kind of know my way around Applescript but everything else is a total mystery to me. So here it is: The Workflow uses "tag" (https://github.com/jdberry/tag/ - installed via homebrew, if that matters) to assign my custom tags to files selected in Finder. The workflow should work with a hotkey - be it via a "selection in macOS"-hotkey or by telling Finder to get the selection. It should work with multiple files. The tags will be specified inside the script (I will duplicate the script for the handful of tags that I use daily). Edit: nevermind, the bash script works now for some reason... I will never understand this stuff. I give up on the Applescript Cheers, Anna on alfred_script(q) set tagName to "paid" set text item delimiters to tab set filePaths to text items of q set text item delimiters to "" repeat with thisPath in filePaths set theFilePath to POSIX path of (thisPath as text) do shell script "/usr/local/bin/tag --add " & tagName & " " & theFilePath end repeat end alfred_script query="{query}" /usr/local/bin/tag --add paid {query} echo -n $query
  2. I tried running this script in a workflow #!/usr/local/bin/bash string="a FeW WOrdS" string=${string,,} echo "$string" But then in the Alfred workflow debugger, I get /Users/me/Library/Caches/com.runningwithcrayons.Alfred/Workflow Scripts/A4DF2A96-E3FC-4D43-BAEC-BD9CDFAA265E: line 10: ${string,,}: bad substitution This script works in my normal terminal, so why doesn't it work in an Alfred script?
  3. Does anyone have an Applescript to run commands in the Alacritty terminal emulator instead of the default one? I've been trying to adapt iterm2 ones but I'm not well versed in Applescript and cannot get it to work.
  4. I feel like I must be too stupid to use Alfred and maybe I shouldn't even try to do this anymore. I just want to take the output of a bash command and post to OSX Notification; I honestly can't believe how so dramatically different (difficult/frustration/inane) trying to do this simple thing is compared with the amazing ease of use and simple to understand the rest of Alfred typically is. I will post my workflow as it is currently, but it should be noted this is perhaps the 37th attempt to figure it out: Workflow view attached, where contents of 'Terminal Command' are as follows: export LPR LPR=$(/usr/local/bin/xmda -l | grep {query}) echo $LPR Terminal Command xmda is simply a program (which works perfectly fine at bash prompt) that outputs a number of lines of text. Here I am simply filtering that output using grep, and again this works at a bash prompt without fail. I am using the full path, although that is not necessary at a bash prompt (however it works either way, this is not a path issue). Post Notification As the image shows, I have {query} in the Text field, conforming I believe anyway, to the ahem, unique manner in which Alfred requires {query} to be used as a "placeholder" variable of sorts, rather than simply allowing normal variable use. Neverminding the latter, I am confounded and feel like I am doing this right. I have searched and read numerous articles and this forum, but each bit of help I can find either seems to fail for me or doesn't come quite close enough to do exactly what I am trying to in this case —leaving me to wonder if there is something "off". I have tried to do something like this perhaps a dozen times in Alfred, each time going away insanely frustrated --I can get around in bash and understand basic programming reasonably well. I think that contributes to the way I feel and why I always end up walking away from each effort. here' s the part where I get schooled, and I stand humbly by with great appreciation for any help that can be provided by those more knowledgeable (and patient) than I! --Thank you for reading.
  5. Hey All, Looking for a solution on a very minor annoyance, I usually run a lot of shell commands from Alfred using the > prefix, which is great! Love it! However, when it executes the command it pops open terminal and runs the command and leaves another lingering window around which I find annoying. Does anyone know of a way to force Alfred to close the window it opens after the command is executed? Very rarely do I need the returned command's output. It's usually for firing off quick things like docker pulls, file moves, git commits and such. If I need to do this through an AppleScript I'm open to that as well, just wanted to find some way around my terminal windows popping up everywhere like mushrooms. Thanks!
  6. I'm trying create a workflow to utilize the MacOS Say command. With this command, I'd like to queue up several paragraphs for it to speak and highlight the spoken paragraph. I'm close, but I'm running into issue with the clipboard management. It was my understanding that the /bin/bash scripts can queue commands up in sequence. In which case the below code should execute like this; 1. Copy the query (which in my workflow is the selected text). 2. Open find in Safari 3. Paste the clipboard contents. 4. Say the selected text. It looks like the LAST copied text ends up being pasted, instead of in sequence. The say command adheres to the sequence properly. The other commands do not, what am I missing? screenshot of the workflow is attached. pbcopy < "{query}" osascript -e 'tell application "System Events" to keystroke "f" using command down' osascript -e 'tell application "System Events" to keystroke "v" using command down' say "{query}" -r 250
  7. Hi there, I'm a newbie to Alfred and completey overwhelmed by the possibilities of its workflows. As such, I have a newbie question but google and the search engine of this forum could not help me. In a workflow I'm using the (Action => Run Script) element to call a bash script that resides in my home folder. This bash script returns 0 in case everything is fine and a different number else. I'm now interested to evaluate this result but don't quite manage to get this done. Do I have to pass the result of the script into some variable of Alfred after calling the script? (at the moment the Run Script element only comprises one line). The filter element looks like what I'm searching for but it is not quite working. Obviously the output from the script does not really end up in the filter.... Any suggestions would be greatly appreciated Have a nice Sunday! Nils
  8. Is it possible to easily run custom bash scripts with Alfred, but run them from my local machine, instead of typing them into Alfred? For example, if I have the following script: ➜ xdoc git:(master) ✗ pwd /Users/max/Dropbox/work/src/github.com/mbigras/xdoc ➜ xdoc git:(master) ✗ ls README.md xcats xdoc xdoc.mm ➜ xdoc git:(master) ✗ readlink xcats /Users/max/Dropbox/work/src/github.com/mbigras/xdoc/xcats ➜ xdoc git:(master) ✗ cat xcats #!/usr/bin/env bash echo inside xcats with args: $@ with the following workflow, I get the following error, please see attached images. So I'm wondering how can I pipe alfred output into my bash scripts without manually writing them inside the Alfred IDE? Thanks
  9. Hi, I want to set a custom bash (source "${HOME}/.zshrc") when running all the scripts in my workflow. There's any elegant way of doing this or I have to set it on the first line of each script?
  10. I have a workflow that is listening for spotify ads (so i can mute them). I have a while loop listening. When it finds an ad (a track with < 35 second duration), it sends a notification - but not an alfred style post notification; just the default applescript-like notification. Here's the code: Note: osascript -e "display notification \"Muting ad for $sleepDuration seconds\" with title \"Mute Spotify Ads\"" This is what I'd like to replace with an alfred Post Notification. vol=`osascript -e 'tell application "Spotify" to sound volume as integer'`; while : do state=`osascript -e 'tell application "Spotify" to player state as string'`; sleepDuration=1 if [ $state = "playing" ]; then duration=`osascript -e 'tell application "Spotify" to duration of current track as string'`; duration=$(echo "$duration / 1000" | bc); if [ $duration -le 35 ]; then position=`osascript -e 'tell application "Spotify" to player position as string'`; position=$(echo "$position" | bc); sleepDuration=$(echo "$duration - $position" | bc); osascript -e "tell application \"Spotify\" to set sound volume to 1"; if [ $sleepDuration -le 0 ]; then sleepDuration=1; else osascript -e "display notification \"Muting ad for $sleepDuration seconds\" with title \"Mute Spotify Ads\"" sleep $sleepDuration; osascript -e "tell application \"Spotify\" to set sound volume to $vol"; sleepDuration=1; fi else osascript -e "tell application \"Spotify\" to set sound volume to $vol"; sleepDuration=1; fi sleep $sleepDuration; else break; fi done osascript -e "tell application \"Spotify\" to set sound volume to $vol";
  11. Hi! I have been a user of Alfred (+ Powerpack) for years, but only recently decided to invest more time into customizing it with the workflows I thought were helpful. As I am a software developer, I generally setup any new Mac OSX environment using a completely automated installer: https://github.com/kigster/pullulant I wanted to add to Pullulant a simple bash script for installing Alfred. I can install the software itself using Homebrew, and then I was hoping to download and install my favorite workflows. I have now spent over an hour searching online, and I am absolutely stunned to find out that Alfred, the supposedly tool for automating your OS-X life, is itself so difficult to automate!!! What I want is a single line command I can run in Terminal (or iTerm, i.e. bash), that tells Alfred to import the given workflow. Since Alfred insists on choosing a category for a workflow (which is completely useless in my opinion), I would imagine that this command would need to tell Alfred what category to assign it. Right now I am able to do this: open $(curl -s -L -O -w %{filename_effective} \ https://github.com/packal/repository/raw/master/com.alfredapp.mdeboer.atom/atom.alfredworkflow) And as you would expect, curl downloads the file, OSX then opens Alfred, which then stays open like a village fool waiting for me to choose a category for it, and I can't, for the love of life, my laptop or the universe, find a way to make this entire process non-interactive, so that I can run it in a goddamn loop and be done with it. Why!? Why is it so hard? LOL. Cry. LOL. Cry. Sorry, it's very late, and I am getting a bit delirious. I do not mean to offend anyone, I just hoped that I could find a solution without having to post a new question in the forum, because even after searching this entire forum for "install", "command line", "bash", "terminal", "non-interactive" I found nada. Your truly, Konstantin https://github.com/kigster
  12. Trying to pass multiple paths from file action as args to a command in a bash script. Is there a way to do this?
  13. Can anyone suggest a way or sketch a workflow to be able to run shell scripts from alfred directly? Example: Say I have a example.sh in /home/folder/ I'd like to be able to run this from Alfred; i.e. the following sequence of events happen: 1. I type example. 2. example.sh shows up in the list of results. 3. I [hotkey] to the options menu of example. 4. I [hotkey] something (a workflow?) to execute the script (in /home/folder).
  14. G'day folks! I've recently dug into writing a workflow for Alfred which purpose is to control Hyperion (a service which supplies LED stripes with data). However, when I'm trying to ssh into the remote machine to fetch a list of all available colors (148 ones), it apparently takes too long. Now, I've read on the forum that Alfred has no such thing as timeout. But in that case, I would love if someone could explain why I can fetch the list of effects, where there are only 14 lines and not the list of colors (148). Is there anything I can do? Oh, and yeah: I've seen the setting "terminate script on subsequent input setting", but I cannot find it no more. I thought I could test without that setting, but I don't seem to find it anymore. Edit: found the setting. Whatever setting I had didn't matter. If I run the script in the terminal, the file with the list creates just fine. It's only an issue when using Alfred. Thankful for answers.
  15. My goal is to automate the process of updating a user's hosts file. (/etc/hosts/) I have a bash script that works fine if I run it from my home directory. User opens Alfred and types in the keyword "hostsup" (No arguments required) Alfred opens a Terminal window and runs a script that has been added to the Workflow folder The script displays some informative text for the user Then the scripts ask the user if they would like to continue On 'y', the terminal prompts the user for their password (Because the command uses sudo) The script outputs a completion message and instructs the user to close the Terminal window If I use "Keyword to Script", I can embed the script as part of the Workflow and run it, but it does not run interactively, so the user receives no prompts or messages. If I use "Keyword to Terminal Command", I can run a simple bash "one-liner", but I can't figure out how to call the script that I've included in the Workflow folder. Any help would be greatly appreciated.
  16. Hi everyone! For long, I've been launching VirtualBox's virtual machines with the following script, bin/bash being the language selected: VBoxManage startvm "vm_name" In a recent update, it seems that VirtualBox moved the necessary "files" (I don't really know/understand what happens in the background) from /usr/bin to /usr/local/bin. See this topic: https://forums.virtualbox.org/viewtopic.php?f=8&t=68825. People there pointed that it might be related to recent security restrictions in OS X (Yosemite, El Capitan). From the Terminal, when I first point to /usr/local/bin, the previous piece of code works perfectly. So my question is, how can I point to that special directory from a Run script window of a workflow? Ultimately, should Alfred be updated to offer /usr/local/bin in the Language list? Thanks for your help!
  17. I was sitting there in iTerm thinking "wouldn't it be great if I could talk to Alfred directly from the terminal"? bash completion, etc. I'm not sure how to get this done; I was hoping for some guidance by the authors. Alfred's AppleScript library only exposes a few functions. If I wanted to use completion, I'd need a list of all of its keywords. However, if that list existed, I'm sure I could work something out. It'd be pretty awesome. Chris
  18. Hi, my first post is a little bit long, but I spent some days in Google before posting here, so I hope to get help. I am trying to create workflow using AppleScript that creates Mail message for me with some links in the footer of the mail body. The problem is that I can't insert links this way, because it places this html as Plain text instead of Rich text: set FooterText to "<a href=\"http://example.com\">Example link</a>" I was trying to find a way to convert html text to Rich text, and found that it can be done with "textutil" from a Terminal app. Running this command from Terminal app works fine: echo '<a href="http://example.com">Example link</a>'|textutil -inputencoding UTF-8 -format html -convert rtf -stdin -stdout|LC_CTYPE=UTF-8 pbcopy I can then open Mail app and paste "Example link" as a rich text, and this link is working. However I can't do the same using "do shell script" from Applescript (NSAppleScript). First I thought it is something to do with escaping characters, so I did a test with <b>bold</b>, but it didn't work, too. Then instead of using "do shell script" I tried "do script" by telling application "Terminal" same script that was working in Terminal app, but it doesn't work from AppleScript, too: on alfred_script(q) set myHtmlText to "<b>bold example</b>" tell application "Terminal" do script "echo " & quoted form of myHtmlText & |textutil -inputencoding UTF-8 -format html -convert rtf -stdin -stdout|LC_CTYPE=UTF-8 pbcopy" end tell end alfred_script Error msg says: "Expected end of line but found identifier." pointing to "|" before LC_CTYPE Any ideas why it is not working? Thanks in advance, Romans
  19. 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)?
  20. 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?
  21. 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
  22. 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
  23. 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...
  24. 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
  25. Hello everyone! I wanted to attempt to create a workflow that does the following: Open a specific Google Chrome profile, wether or not google chrome is already open or not. I have tried this just in a bash script and never got the results I wanted..... This is what I was working off of: open -a Google\ Chrome --args --"profile-directory"="Profile 1 also tried /Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome --args --profile-directory=Default This is where i posted my original question: http://superuser.com/questions/759535/open-google-chrome-specific-profile-from-command-line-mac/759644#759644 So has anyone done this before, or have any ideas on how to create this into an alfred workflow? Thank you!
×
×
  • Create New...