diff options
| author | 2020-02-28 14:24:05 +0100 | |
|---|---|---|
| committer | 2020-02-28 14:24:05 +0100 | |
| commit | 0a3091583a1470b610457eda0691428af6c3f14c (patch) | |
| tree | 7bf849d098c2e60ed64d14bd90f8e5181a12e35f | |
| parent | 639e02e2694c6d8fc8f40e05fd221e40c9f9f2ba (diff) | |
| download | dotfiles-0a3091583a1470b610457eda0691428af6c3f14c.tar.gz dotfiles-0a3091583a1470b610457eda0691428af6c3f14c.tar.bz2 dotfiles-0a3091583a1470b610457eda0691428af6c3f14c.zip | |
Added bash completion for lastpass
| -rwxr-xr-x | bash/.bashrc | 51 |
1 files changed, 47 insertions, 4 deletions
diff --git a/bash/.bashrc b/bash/.bashrc index a5d7357..b910453 100755 --- a/bash/.bashrc +++ b/bash/.bashrc | |||
| @@ -25,6 +25,7 @@ export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.local/usr/lib" | |||
| 25 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.local/usr/local/lib" | 25 | export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:$HOME/.local/usr/local/lib" |
| 26 | 26 | ||
| 27 | export ANDROID_HOME="$HOME/Android/Sdk" | 27 | export ANDROID_HOME="$HOME/Android/Sdk" |
| 28 | export PATH="$PATH:$ANDROID_HOME/platform-tools" | ||
| 28 | 29 | ||
| 29 | # Quit the shell like in vim | 30 | # Quit the shell like in vim |
| 30 | alias :q="exit" | 31 | alias :q="exit" |
| @@ -35,10 +36,17 @@ case "$(uname)" in | |||
| 35 | alias ls="ls --color=auto" | 36 | alias ls="ls --color=auto" |
| 36 | usr="/usr" | 37 | usr="/usr" |
| 37 | ;; | 38 | ;; |
| 38 | FreeBSD|Darwin) | 39 | Darwin) |
| 40 | |||
| 41 | alias flushdns="sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache" | ||
| 39 | alias ls="ls -G" | 42 | alias ls="ls -G" |
| 40 | usr="/usr/local" | 43 | usr="/usr/local" |
| 41 | ;; | 44 | ;; |
| 45 | FreeBSD) | ||
| 46 | alias ls="ls -G" | ||
| 47 | usr="/usr/local" | ||
| 48 | ;; | ||
| 49 | |||
| 42 | esac | 50 | esac |
| 43 | 51 | ||
| 44 | # Colorfull manpages | 52 | # Colorfull manpages |
| @@ -192,9 +200,44 @@ elif exists screenfetch; then | |||
| 192 | screenfetch | 200 | screenfetch |
| 193 | fi | 201 | fi |
| 194 | 202 | ||
| 195 | BASH_COMPLETION="$(brew --prefix)/etc/bash_completion" | 203 | if exists brew; then |
| 196 | if exists brew && [ -f "${BASH_COMPLETION}" ]; then | 204 | BASH_COMPLETION="$(brew --prefix)/etc/bash_completion" |
| 197 | source "${BASH_COMPLETION}" | 205 | if [ -f "${BASH_COMPLETION}" ]; then |
| 206 | source "${BASH_COMPLETION}" | ||
| 207 | fi | ||
| 208 | fi | ||
| 209 | |||
| 210 | if exists lpass; then | ||
| 211 | if exists complete; then | ||
| 212 | _complete_lpass_accounts() { | ||
| 213 | local search items item cmp newline | ||
| 214 | |||
| 215 | newline=' | ||
| 216 | ' | ||
| 217 | |||
| 218 | cmp=${COMP_WORDS[COMP_CWORD]} | ||
| 219 | search="$(sed 's/\\\ /___/g' <<< $cmp)" | ||
| 220 | items=$(lpass ls --format "%an$newline%aN" | sed "s/\ /___/g") | ||
| 221 | |||
| 222 | for item in $items; do | ||
| 223 | if [[ $item =~ ^$search ]]; then | ||
| 224 | COMPREPLY+=( "$(sed 's/___/\\\ /g' <<< $item)" ) | ||
| 225 | fi | ||
| 226 | done | ||
| 227 | } | ||
| 228 | |||
| 229 | complete -F _complete_lpass_accounts lpcp | ||
| 230 | fi | ||
| 231 | |||
| 232 | lps() { | ||
| 233 | lpass ls --format "%aN" | grep $1 | ||
| 234 | } | ||
| 235 | |||
| 236 | lpcp() { | ||
| 237 | lpass show --password "$1" | pbcopy | ||
| 238 | sleep 1 | ||
| 239 | lpass show --username "$1" | pbcopy | ||
| 240 | } | ||
| 198 | fi | 241 | fi |
| 199 | 242 | ||
| 200 | # heroku autocomplete setup | 243 | # heroku autocomplete setup |
