/ dot_config / shells / functions.sh
functions.sh
 1  #!/bin/sh
 2  
 3  pdfmerge() {
 4      output="$1"
 5      shift
 6      gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dNOPAUSE -dQUIET -dBATCH -dDetectDuplicateImages -dCompressFonts=true -r150 -sOutputFile="$output" "$@"
 7  }
 8  
 9  mkdircd() {
10      mkdir -p "$1" || exit
11      cd "$1" || exit
12  }
13  
14  zat() {
15      cd ~/Documents || exit
16      file="$(fzf)"
17      wait $!
18      zathura "$file" & exit
19  }
20  
21  open() {
22      file="$(fzf)"
23      wait $!
24      xdg-open "$file" & exit
25  }
26  
27  # Change working dir in shell to last dir in lf on exit (adapted from ranger).
28  #
29  # You need to either copy the content of this file to your shell rc file
30  # (e.g. ~/.bashrc) or source this file directly:
31  #
32  #     LFCD="/path/to/lfcd.sh"
33  #     if [ -f "$LFCD" ]; then
34  #         source "$LFCD"
35  #     fi
36  #
37  # You may also like to assign a key to this command:
38  #
39  #     bind '"\C-o":"lfcd\C-m"'  # bash
40  #     bindkey -s '^o' 'lfcd\n'  # zsh
41  lf () {
42      # Quit shell if nested instead
43      [ "$LF_LEVEL" -eq 1 ] && exit
44      tmp="$(mktemp)"
45      $(which lf) -last-dir-path="$tmp" "$@"
46      if [ -f "$tmp" ]; then
47          dir="$(cat "$tmp")"
48          rm -f "$tmp"
49          if [ -d "$dir" ]; then
50              if [ "$dir" != "$(pwd)" ]; then
51                  cd "$dir" || exit
52              fi
53          fi
54      fi
55  }
56  
57  jump() {
58     cd "$(find . -maxdepth 1 -type d | fzf --height 40% --reverse --header='Jump to location')"
59  }
60  
61  sigtermprocess() {
62      kill -15 "$(pidof "$1")"
63  }
64  
65  sigkillprocess() {
66      kill -9 "$(pidof "$1")"
67  }
68  
69  morg() { # $1 man page
70      man -T html "$1" | pandoc --wrap none -r html -w org -L "$XDG_CONFIG_HOME/lua-filters/remove-header-attr.lua" > sudoers.org
71  }