Add ssh and key related aliases and reformat all fish files

This commit is contained in:
mitchell 2020-10-31 18:13:25 -04:00
parent 0ef8fb571a
commit 7a361e5260
10 changed files with 72 additions and 54 deletions

View File

@ -7,6 +7,7 @@ function configure_fish
define_global_variables
import_sources $uname
define_aliases $uname
ssh_agent_startup
end
configure_fish

View File

@ -2,5 +2,5 @@ function back -d 'A shortcut for backgrounding a command using nohup and named l
set log_name (string join _ $argv)
echo "log file: $log_name.out"
nohup $argv > "$log_name.out" &
nohup $argv >"$log_name.out" &
end

View File

@ -1,24 +1,30 @@
function define_aliases -a uname -d 'Defines aliases for commonly used commands'
alias cp 'rsync -aP'
alias rcp 'rsync -aP'
alias dm 'docker-machine'
alias v 'nvim +FZF'
alias v 'nvim +FZF'
alias vg 'vagrant'
alias tf 'terraform'
alias tocb 'xclip -in -selection clipboard'
alias fromcb 'xclip -out -selection clipboard'
alias ssh-rm-host 'ssh-keygen -f ~/.ssh/known_hosts -R'
alias ssh-rm 'ssh-keygen -f ~/.ssh/known_hosts -R'
alias wiki 'nvim +VimwikiIndex'
alias ssh-a 'ssh-add ~/.secrets/id_ed25519'
alias age-p 'age --armor --passphrase'
alias age-d 'age --decrypt --identity ~/.secrets/id_ed25519'
alias age-e 'age --armor --recipient (cat ~/.secrets/id_ed25519.pub)'
alias age-k 'age --decrypt --identity ~/.secrets/id_ed25519 ~/.secrets/age_keys.age'
switch "$uname"
case 'Linux'
alias cat 'batcat --theme ansi-dark'
alias goland 'command goland'
alias rider 'command rider'
alias bat 'batcat --theme ansi-dark'
alias goland 'command goland'
alias rider 'command rider'
alias webstorm 'command webstorm'
alias sctl 'sudo systemctl'
case 'Darwin'
alias cat 'bat --theme ansi-dark'
alias goland 'open -a Goland'
alias rider 'open -a Rider'
alias bat 'bat --theme ansi-dark'
alias goland 'open -a Goland'
alias rider 'open -a Rider'
alias webstorm 'open -a Webstorm'
end
end

View File

@ -6,18 +6,18 @@ function editcb -a ft -d 'Opens your editor to the cliboard\'s current contents.
switch "$uname"
case 'Linux'
xclip -out -selection clipboard > $file
xclip -out -selection clipboard >$file
case 'Darwin'
pbpaste > $file
pbpaste >$file
end
$EDITOR $file
switch "$uname"
case 'Linux'
xclip -in -selection clipboard < $file
xclip -in -selection clipboard <$file
case 'Darwin'
pbcopy < $file
pbcopy <$file
end
rm $file

View File

@ -13,7 +13,7 @@ function fish_prompt --description 'Write out the prompt'
end
# Set jobs num, based on exit code of jobs command
if jobs > /dev/null
if jobs >/dev/null
set -l jobs_out (jobs -c)
set jobs_num '[' (set_color grey) (count $jobs_out) (set_color normal) '] '
end
@ -31,49 +31,53 @@ function fish_prompt --description 'Write out the prompt'
if test $fish_key_bindings = 'fish_vi_key_bindings'
switch "$fish_bind_mode"
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '###'
case 'visual'
set suffix (set_color bryellow) '<~#' (set_color normal)
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '###'
case 'visual'
set suffix (set_color bryellow) '<~#' (set_color normal)
end
end
case '*'
set color_cwd $fish_color_cwd
set suffix '$~>'
if test $fish_key_bindings = 'fish_vi_key_bindings'
switch "$fish_bind_mode"
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '<$>'
case 'visual'
set suffix (set_color bryellow) '<~$' (set_color normal)
case 'insert'
set suffix (set_color brblue) $suffix (set_color normal)
case 'default'
set suffix '<$>'
case 'visual'
set suffix (set_color bryellow) '<~$' (set_color normal)
end
end
end
# Set user_prefix, based on whether or not inside of ssh session.
if test -n "$SSH_CLIENT"; set user_prefix $USER @ (prompt_hostname) ' '; end
if test -n "$SSH_CLIENT"
set user_prefix $USER @ (prompt_hostname) ' '
end
# Show current git branch, based on git commands only.
if git status > /dev/null 2>&1
if git status >/dev/null 2>&1
set -l branch_color green
set -l git_status (git status)
if string match 'Changes not staged for commit:' $git_status > /dev/null
or string match 'Untracked files:' $git_status > /dev/null
if string match 'Changes not staged for commit:' $git_status >/dev/null
or string match 'Untracked files:' $git_status >/dev/null
set branch_color red
else if string match 'Changes to be committed:' $git_status > /dev/null
else if string match 'Changes to be committed:' $git_status >/dev/null
set branch_color yellow
end
set -l cur_branch (string sub -s 3 (string match -r '^\* .*$' (git branch)))
if string match -q '(HEAD detached*' $cur_branch; set cur_branch 'detached'; end
if string match -q '(HEAD detached*' $cur_branch
set cur_branch 'detached'
end
if test -n "$cur_branch"
set -l cur_branch_len (string length $cur_branch)
@ -83,10 +87,10 @@ function fish_prompt --description 'Write out the prompt'
end
end
if string match 'Your branch is ahead of*' $git_status > /dev/null
set cur_branch $cur_branch \u21A5
else if string match 'Your branch is behind*' $git_status > /dev/null
set cur_branch $cur_branch \u21A7
if string match 'Your branch is ahead of*' $git_status >/dev/null
set cur_branch $cur_branch \u21A5
else if string match 'Your branch is behind*' $git_status >/dev/null
set cur_branch $cur_branch \u21A7
end
set git_branch ' on ' (set_color $branch_color) $cur_branch (set_color normal)

View File

@ -3,7 +3,10 @@ function import_sources -a uname -d 'Loads any additional fish files needed at i
switch "$uname"
case 'Linux'
test -e ~/.asdf/asdf.fish; and source ~/.asdf/asdf.fish
test -e ~/.asdf/asdf.fish
and source ~/.asdf/asdf.fish
and mkdir -p ~/.config/fish/completions
and cp ~/.asdf/completions/asdf.fish ~/.config/fish/completions
case 'Darwin'
command -q brew
and test -e (brew --prefix asdf)/asdf.fish

View File

@ -1,17 +1,19 @@
function send_push -a message -d 'Send a push notification to your phone via pushover (optional delay as second arg)'
if test -n "$argv[2]"; sleep $argv[2]; end
if test -n "$argv[2]"
sleep $argv[2]
end
set payload \
"{
set payload \
"{
\"token\": \"$pushover_token\",
\"user\": \"$pushover_user\",
\"title\": \"Tasks\",
\"message\": $message
}"
curl \
-X POST \
-H 'Content-Type: application/json' \
-d $payload \
https://api.pushover.net/1/messages.json
curl \
-X POST \
-H 'Content-Type: application/json' \
-d $payload \
https://api.pushover.net/1/messages.json
end

View File

@ -1,4 +1,6 @@
function tasko -a id -d 'Open the link of a taskwarrior task by id'
set link (task _get $id.link)
if test -n $link; open $link; end
if test -n $link
open $link
end
end

View File

@ -4,6 +4,6 @@ function tasktime -a id time -d 'Set a time to check-in on task progress using p
task $id start
fish -c "send_push '\"Half-time: $desc\"' $half_time" > /dev/null & disown
fish -c "send_push '\"Timer over: $desc\"' $time" > /dev/null & disown
fish -c "send_push '\"Half-time: $desc\"' $half_time" >/dev/null & disown
fish -c "send_push '\"Timer over: $desc\"' $time" >/dev/null & disown
end

View File

@ -16,8 +16,8 @@ set -U fish_color_operator 00a6b2
set -U fish_color_param 839496
set -U fish_color_quote 657b83
set -U fish_color_redirection 6c71c4
set -U fish_color_search_match 'bryellow' '--background=black'
set -U fish_color_selection 'white' '--bold' '--background=brblack'
set -U fish_color_search_match 'bryellow' '--background=black'
set -U fish_color_selection 'white' '--bold' '--background=brblack'
set -U fish_color_status red
set -U fish_color_user brgreen
set -U fish_color_valid_path --underline
@ -25,5 +25,5 @@ set -U fish_greeting
set -U fish_key_bindings fish_vi_key_bindings
set -U fish_pager_color_completion B3A06D
set -U fish_pager_color_description B3A06D
set -U fish_pager_color_prefix 'cyan' '--underline'
set -U fish_pager_color_progress 'brwhite' '--background=cyan'
set -U fish_pager_color_prefix 'cyan' '--underline'
set -U fish_pager_color_progress 'brwhite' '--background=cyan'