diff options
author | Rasmus Steinke <rasi@xssn.at> | 2016-07-28 17:27:34 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-07-28 17:27:34 +0200 |
commit | 77628775ac4601a681b6bd5fa984050fee622365 (patch) | |
tree | 2c9f4c76db36c684e73088680b03e7ff1884de77 | |
parent | c2f83edb75cb82a260597c46da8820d00b497628 (diff) | |
parent | 0379ab4ef1e5dcfe24a63fb3127b13a025ae4d1b (diff) | |
download | rofi-pass-77628775ac4601a681b6bd5fa984050fee622365.tar.gz |
Merge pull request #47 from gregf/bsd_support
Add support for BSD
-rw-r--r-- | README.md | 4 | ||||
-rwxr-xr-x | addpass | 2 | ||||
-rwxr-xr-x | rofi-pass | 13 |
3 files changed, 14 insertions, 5 deletions
@@ -46,6 +46,10 @@ In addition to those `:enter` and `:delay` are available. * gawk * bash +### BSD +* gnugrep +* gawk + ## Configuration rofi-pass may read its configuration values from `/etc/rofi-pass` and/or `$HOME/.config/rofi-pass/config`. For an example configuration please take a look at the included `config.example` file. @@ -1,4 +1,4 @@ -#!/bin/bash +#!/usr/bin/env bash source $HOME/.config/rofi-pass/config @@ -4,6 +4,11 @@ # (c) 2015 Rasmus Steinke <rasi@xssn.at> basecommand=$(echo "$0" | gawk '{ print $1 }') +case "$OSTYPE" in + *bsd*) GREP='/usr/local/bin/grep' ;; + linux*) GREP='/usr/bin/grep' ;; + *) echo 'OS not supported, patches welcome' && exit 1 ;; +esac # get all password files and create an array list_passwords() { @@ -74,7 +79,7 @@ autopass () { openURL () { checkIfPass - $BROWSER "$(pass "$selected_password" | grep "${URL_field}: " | gawk '{sub(/:/,"")}{print $2}1' | head -1)"; exit; + $BROWSER "$(pass "$selected_password" | $GREP "${URL_field}: " | gawk '{sub(/:/,"")}{print $2}1' | head -1)"; exit; clearUp } @@ -219,7 +224,7 @@ Type field of entry with <span color='$help_color'>Enter</span>. For more help h _id="${LINE%%: *}" _val="${LINE#* }" stuff["${_id}"]=${_val} - done < <(echo "${password_temp}" | tail -n+2 | grep -P '(: |:\t)' ) + done < <(echo "${password_temp}" | tail -n+2 | $GREP -P '(: |:\t)' ) stuff["pass"]=${password} if test "${stuff['autotype']+autotype}" then @@ -344,7 +349,7 @@ showEntry () { _id=$(echo "${LINE}" | gawk -F ':[[:space:]]*' '{print $1}') _val=$(echo "${LINE}" | gawk '{sub(/:/,"")}{for (i=2; i<NF; i++) printf $i " "; print $NF}') stuff["${_id}"]=${_val} - done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | grep -P '(: |:\t)' ) + done < <(PASSWORD_STORE_DIR="${root}" pass "${selected_password}" | tail -n+2 | $GREP -P '(: |:\t)' ) stuff["pass"]=${password} word=$(echo "$bla" | gawk -F': ' '{print $1}') @@ -499,7 +504,7 @@ fi # set help color if [[ $help_color == "" ]]; then - help_color=$(rofi -dump-xresources | grep 'rofi.color.normal' | gawk -F ',' '/,/{gsub(/ /, "", $2); print $2}') + help_color=$(rofi -dump-xresources | $GREP 'rofi.color.normal' | gawk -F ',' '/,/{gsub(/ /, "", $2); print $2}') fi # check for BROWSER variable, use xdg-open as fallback |