diff --git a/config/fish/functions/fgrep.fish b/config/fish/functions/fgrep.fish index 33fd710..9dac9ae 100644 --- a/config/fish/functions/fgrep.fish +++ b/config/fish/functions/fgrep.fish @@ -1,7 +1,7 @@ function fgrep - if type -q ggrep - command ggrep -F --color=auto $argv - else - command fgrep --color=auto $argv - end + if type -q ggrep + command ggrep -F --color=auto $argv + else + command fgrep --color=auto $argv + end end diff --git a/config/fish/functions/fish_prompt.fish b/config/fish/functions/fish_prompt.fish index 980ad12..ae6335d 100644 --- a/config/fish/functions/fish_prompt.fish +++ b/config/fish/functions/fish_prompt.fish @@ -1,22 +1,22 @@ function fish_prompt --description 'Write out the prompt' - set -l suffix - switch "$USER" - case root toor - set suffix (set_color $fish_color_cwd_root)'#' - case '*' - set suffix '>' - end + set -l suffix + switch "$USER" + case root toor + set suffix (set_color $fish_color_cwd_root)'#' + case '*' + set suffix '>' + end - set -l branch (git symbolic-ref HEAD 2>/dev/null) - set branch (string replace -r "^refs/heads/" "" $branch) - set -l vcs - if test -n "$branch" -a "$branch" != "master" - set vcs (set_color $fish_color_vcs_braces)"(" \ - (set_color $fish_color_vcs)"$branch" \ - (set_color $fish_color_vcs_braces)")" - end + set -l branch (git symbolic-ref HEAD 2>/dev/null) + set branch (string replace -r "^refs/heads/" "" $branch) + set -l vcs + if test -n "$branch" -a "$branch" != "master" + set vcs (set_color $fish_color_vcs_braces)"(" \ + (set_color $fish_color_vcs)"$branch" \ + (set_color $fish_color_vcs_braces)")" + end - echo -n -s (set_color $fish_color_host) (prompt_hostname) ' ' \ - (set_color $fish_color_cwd) (prompt_pwd) (string join '' $vcs) \ - (set_color $fish_color_suffix) $suffix (set_color normal) ' ' + echo -n -s (set_color $fish_color_host) (prompt_hostname) ' ' \ + (set_color $fish_color_cwd) (prompt_pwd) (string join '' $vcs) \ + (set_color $fish_color_suffix) $suffix (set_color normal) ' ' end diff --git a/config/fish/functions/fish_right_prompt.fish b/config/fish/functions/fish_right_prompt.fish index 5480f89..87196f3 100644 --- a/config/fish/functions/fish_right_prompt.fish +++ b/config/fish/functions/fish_right_prompt.fish @@ -1,15 +1,15 @@ function fish_right_prompt - set -l code $status - set -l jobs (jobs | wc -l) - set -l prompt + set -l code $status + set -l jobs (jobs | wc -l) + set -l prompt - test $jobs -gt 0 - and set -a prompt (set_color $fish_color_jobs)$jobs + test $jobs -gt 0 + and set -a prompt (set_color $fish_color_jobs)$jobs - test $code -gt 0 - and set -a prompt (set_color $fish_color_status)$code + test $code -gt 0 + and set -a prompt (set_color $fish_color_status)$code - echo $prompt + echo $prompt - set_color normal + set_color normal end diff --git a/config/fish/functions/fish_title.fish b/config/fish/functions/fish_title.fish index 874d7ce..a8f2b85 100644 --- a/config/fish/functions/fish_title.fish +++ b/config/fish/functions/fish_title.fish @@ -1,3 +1,3 @@ function fish_title - echo (status current-command) · (prompt_pwd) · (prompt_hostname) + echo (status current-command) · (prompt_pwd) · (prompt_hostname) end diff --git a/config/fish/functions/gpg-sftp.fish b/config/fish/functions/gpg-sftp.fish index ef365ca..d3c4cf1 100644 --- a/config/fish/functions/gpg-sftp.fish +++ b/config/fish/functions/gpg-sftp.fish @@ -1,4 +1,4 @@ function gpg-sftp - set -lx SSH_AUTH_SOCK $HOME/.gnupg/S.gpg-agent.ssh - sftp $argv + set -lx SSH_AUTH_SOCK $HOME/.gnupg/S.gpg-agent.ssh + sftp $argv end diff --git a/config/fish/functions/gpg-ssh-add.fish b/config/fish/functions/gpg-ssh-add.fish index ebcd135..514efdd 100644 --- a/config/fish/functions/gpg-ssh-add.fish +++ b/config/fish/functions/gpg-ssh-add.fish @@ -1,4 +1,4 @@ function gpg-ssh-add - set -lx SSH_AUTH_SOCK $HOME/.gnupg/S.gpg-agent.ssh - ssh-add $argv + set -lx SSH_AUTH_SOCK $HOME/.gnupg/S.gpg-agent.ssh + ssh-add $argv end diff --git a/config/fish/functions/gpg-ssh.fish b/config/fish/functions/gpg-ssh.fish index b952637..9362b2f 100644 --- a/config/fish/functions/gpg-ssh.fish +++ b/config/fish/functions/gpg-ssh.fish @@ -1,4 +1,4 @@ function gpg-ssh - set -lx SSH_AUTH_SOCK $HOME/.gnupg/S.gpg-agent.ssh - ssh $argv + set -lx SSH_AUTH_SOCK $HOME/.gnupg/S.gpg-agent.ssh + ssh $argv end diff --git a/config/fish/functions/grep.fish b/config/fish/functions/grep.fish index 8682a49..8585fa3 100644 --- a/config/fish/functions/grep.fish +++ b/config/fish/functions/grep.fish @@ -1,7 +1,7 @@ function grep - if type -q ggrep - command ggrep --color=auto $argv - else - command grep --color=auto $argv - end + if type -q ggrep + command ggrep --color=auto $argv + else + command grep --color=auto $argv + end end diff --git a/config/fish/functions/ixio.fish b/config/fish/functions/ixio.fish index 99c9f54..2a7b237 100644 --- a/config/fish/functions/ixio.fish +++ b/config/fish/functions/ixio.fish @@ -1,3 +1,3 @@ function ixio - curl -F 'f:1=<-' ix.io + curl -F 'f:1=<-' ix.io end diff --git a/config/fish/functions/ls.fish b/config/fish/functions/ls.fish index 9dd2a36..6c56508 100644 --- a/config/fish/functions/ls.fish +++ b/config/fish/functions/ls.fish @@ -1,7 +1,7 @@ function ls --description 'List contents of directory' - if type -q gls - command gls --color=auto $argv - else - command ls --color=auto $argv - end + if type -q gls + command gls --color=auto $argv + else + command ls --color=auto $argv + end end diff --git a/config/fish/functions/make.fish b/config/fish/functions/make.fish index e994ff2..8fc83e5 100644 --- a/config/fish/functions/make.fish +++ b/config/fish/functions/make.fish @@ -1,15 +1,15 @@ # Automatically use bmake instead of make when using pkgsrc, if necessary function make - if string match -q -r '/pkgsrc$|/pkgsrc/' $PWD - # pkgsrc does not like MAKEFLAGS including -j - set -lx MAKEFLAGS + if string match -q -r '/pkgsrc$|/pkgsrc/' $PWD + # pkgsrc does not like MAKEFLAGS including -j + set -lx MAKEFLAGS - if type -q bmake - command bmake $argv - else - command make $argv - end - else - command make $argv - end + if type -q bmake + command bmake $argv + else + command make $argv + end + else + command make $argv + end end diff --git a/config/fish/functions/mpv.fish b/config/fish/functions/mpv.fish index 8100d7b..f0ef0b6 100644 --- a/config/fish/functions/mpv.fish +++ b/config/fish/functions/mpv.fish @@ -1,5 +1,5 @@ # To work around mpv not liking locales that use , as a decimal separator function mpv - set -x LC_ALL C - command mpv $argv + set -lx LC_ALL C + command mpv $argv end diff --git a/config/fish/functions/pkg_chk.fish b/config/fish/functions/pkg_chk.fish index d6b8db6..de0a9af 100644 --- a/config/fish/functions/pkg_chk.fish +++ b/config/fish/functions/pkg_chk.fish @@ -1,4 +1,4 @@ function pkg_chk - set -lx MAKEFLAGS - command pkg_chk $argv + set -lx MAKEFLAGS + command pkg_chk $argv end diff --git a/config/fish/functions/pkg_rolling-replace.fish b/config/fish/functions/pkg_rolling-replace.fish index b5b1fb6..3837421 100644 --- a/config/fish/functions/pkg_rolling-replace.fish +++ b/config/fish/functions/pkg_rolling-replace.fish @@ -1,4 +1,4 @@ function pkg_rolling-replace - set -lx MAKEFLAGS - command pkg_rolling-replace $argv + set -lx MAKEFLAGS + command pkg_rolling-replace $argv end diff --git a/config/fish/functions/prompt_pwd.fish b/config/fish/functions/prompt_pwd.fish index 95034e0..c92a960 100644 --- a/config/fish/functions/prompt_pwd.fish +++ b/config/fish/functions/prompt_pwd.fish @@ -1,20 +1,19 @@ function prompt_pwd --description 'Print the current working directory' - set -l options 'h/help' - argparse -n prompt_pwd --max-args=0 $options -- $argv - or return + set -l options 'h/help' + argparse -n prompt_pwd --max-args=0 $options -- $argv + or return - if set -q _flag_help - __fish_print_help prompt_pwd - return 0 - end + if set -q _flag_help + __fish_print_help prompt_pwd + return 0 + end - # Replace $HOME with "~" - set realhome ~ - set -l tmp (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD) - set tmp (basename $tmp) + # Replace $HOME with "~" + set realhome ~ + set -l tmp (basename (string replace -r '^'"$realhome"'($|/)' '~$1' $PWD)) - test $PWD = "/$tmp" - and set tmp $PWD + test $PWD = "/$tmp" + and set tmp $PWD - echo $tmp + echo $tmp end diff --git a/config/fish/functions/pw.fish b/config/fish/functions/pw.fish index 91e2eb0..55f8551 100644 --- a/config/fish/functions/pw.fish +++ b/config/fish/functions/pw.fish @@ -1,13 +1,13 @@ function pw - set -l clipboard - if type -q pbcopy - set clipboard pbcopy - else if type -q xclip - set clipboard xclip - else - echo "No clipboard handler found!" - return 1 - end + set -l clipboard + if type -q pbcopy + set clipboard pbcopy + else if type -q xclip + set clipboard xclip + else + echo "No clipboard handler found!" + return 1 + end - cryptopassphrase -k ~/.scrypt-pwgen.key $argv | tr -d '\n' | $clipboard + cryptopassphrase -k ~/.scrypt-pwgen.key $argv | tr -d '\n' | $clipboard end diff --git a/config/fish/functions/pws.fish b/config/fish/functions/pws.fish new file mode 100644 index 0000000..ee6f7e9 --- /dev/null +++ b/config/fish/functions/pws.fish @@ -0,0 +1,14 @@ +function pws + set -l clipboard + if type -q pbcopy + set clipboard pbcopy + else if type -q xclip + set clipboard xclip + else + echo "No clipboard handler found!" + return 1 + end + + cryptopassphrase -k ~/.scrypt-pwgen-server.key $argv \ + | tr -d '\n' | $clipboard +end diff --git a/config/fish/functions/url2pkg.fish b/config/fish/functions/url2pkg.fish index 324fd48..805f8cd 100644 --- a/config/fish/functions/url2pkg.fish +++ b/config/fish/functions/url2pkg.fish @@ -1,5 +1,5 @@ # pkgsrc does not like MAKEFLAGS being set function url2pkg - set -lx MAKEFLAGS - command url2pkg $argv + set -lx MAKEFLAGS + command url2pkg $argv end