nix

configuration files that power my machines
Log | Files | Refs | README | LICENSE

functions (1550B)


      1 #!/bin/zsh
      2 
      3 fzf_copy_from_cliphist() {
      4 	{ cliphist list | fzf --no-sort | cliphist decode | wl-copy && zle reset-prompt || true; } 2>/dev/null
      5 }
      6 
      7 erg() {
      8 	$EDITOR \
      9 		+'/\v'"${1/\//\\/}" \
     10 		+':silent tabdo :1 | normal! n' \
     11 		+':tabfirst' \
     12 		-p $(rg "$@" | cut -d: -f1 | sort -u)
     13 }
     14 
     15 efd() {
     16 	$EDITOR \
     17 		+':tabfirst' \
     18 		-p $(fd "$@")
     19 }
     20 
     21 # https://news.ycombinator.com/item?id=29155825
     22 jog() {
     23 	sqlite3 -csv -header "$HOME/.histdb/zsh-history.db" "
     24         SELECT commands.argv AS command
     25         FROM commands
     26         JOIN history ON history.command_id = commands.id
     27         JOIN places  ON history.place_id   = places.id
     28         WHERE history.exit_status = 0
     29           AND dir         = '${PWD}'
     30           AND places.host = '${HOST}'
     31           AND commands.argv NOT LIKE 'z %'
     32           AND commands.argv NOT LIKE 'cd %'
     33         ORDER BY start_time ASC
     34     " | xan view -A -t borderless -I -M --repeat-headers never --color always |
     35 		sed '/^\x1b\[2m/d; /^$/d'
     36 }
     37 
     38 hs() {
     39 	sqlite3 -csv -header "$HOME/.histdb/zsh-history.db" "
     40         SELECT command FROM (
     41             SELECT commands.argv AS command, history.start_time AS st
     42             FROM commands
     43             JOIN history ON history.command_id = commands.id
     44             ORDER BY history.start_time DESC
     45             LIMIT 1000
     46         ) ORDER BY st ASC
     47     " | xan view -A -t borderless -I -M --repeat-headers never --color always |
     48 		sed '/^\x1b\[2m/d; /^$/d'
     49 }
     50 
     51 for b in $(seq 0 100); do
     52 	alias b"$b"="sudo brightnessctl set $b%"
     53 done
     54 
     55 for t in $(seq 0 100); do
     56 	alias s"$t"="seek $t"
     57 done