fish: overhaul config
This commit is contained in:
parent
2c16fc885c
commit
9ace128d40
@ -4,7 +4,7 @@ My personal configuration files.
|
|||||||
|
|
||||||
##### Usage
|
##### Usage
|
||||||
|
|
||||||
1. Clone this repository into `~/.dotfiles`
|
1. Clone this repository into `~/dotfiles`
|
||||||
2. Install [Homebrew](https://brew.sh/): `./install-brew.sh`
|
2. Install [Homebrew](https://brew.sh/): `./install-brew.sh`
|
||||||
3. Install tools: `brew bundle install --file=brew/Brewfile`
|
3. Install tools: `brew bundle install --file=brew/Brewfile`
|
||||||
4. (Optional) Install more tools: `brew bundle install --file=brew/Brewfile.opt`
|
4. (Optional) Install more tools: `brew bundle install --file=brew/Brewfile.opt`
|
||||||
|
@ -24,8 +24,9 @@ alias afk='pmset displaysleepnow'
|
|||||||
alias dnsflush='sudo killall -HUP mDNSResponder'
|
alias dnsflush='sudo killall -HUP mDNSResponder'
|
||||||
alias java8="export JAVA_HOME=$JAVA_HOME_8"
|
alias java8="export JAVA_HOME=$JAVA_HOME_8"
|
||||||
alias java11="export JAVA_HOME=$JAVA_HOME_11"
|
alias java11="export JAVA_HOME=$JAVA_HOME_11"
|
||||||
alias md5sum="md5 -r $argv"
|
alias md5sum="md5 -r"
|
||||||
alias vi='nvim'
|
alias vi='nvim'
|
||||||
|
alias vim='nvim'
|
||||||
|
|
||||||
# Do not save lines which begin with a space character
|
# Do not save lines which begin with a space character
|
||||||
# Do not save lines which match the previous history entry
|
# Do not save lines which match the previous history entry
|
||||||
|
3
fish/.gitignore
vendored
3
fish/.gitignore
vendored
@ -1,3 +1,4 @@
|
|||||||
fish_variables
|
fish_variables
|
||||||
fisher/
|
fisher/
|
||||||
fisher.fish
|
fish_user_key_bindings.fish
|
||||||
|
fzf_key_bindings.fish
|
||||||
|
@ -4,15 +4,38 @@ set fish_greeting
|
|||||||
# Disable the abbreviated directory format
|
# Disable the abbreviated directory format
|
||||||
set fish_prompt_pwd_dir_length 0
|
set fish_prompt_pwd_dir_length 0
|
||||||
|
|
||||||
# Set global variables
|
# Environment variables
|
||||||
set -x EDITOR nvim
|
set -x EDITOR nvim
|
||||||
set -x LANG en_US.UTF-8
|
set -x LANG en_US.UTF-8
|
||||||
set -x MANPAGER 'nvim +Man!'
|
set -x MANPAGER 'nvim +Man!'
|
||||||
set -x FZF_DEFAULT_COMMAND 'fd --type f'
|
|
||||||
set -x FZF_DEFAULT_OPTS '--height=40% --layout=reverse'
|
|
||||||
set -x JAVA_HOME (/usr/libexec/java_home -v 1.8)
|
set -x JAVA_HOME (/usr/libexec/java_home -v 1.8)
|
||||||
set -x SBT_OPTS '-Dsbt.supershell=false'
|
set -x SBT_OPTS '-Dsbt.supershell=false'
|
||||||
|
|
||||||
|
# FZF (https://github.com/junegunn/fzf)
|
||||||
|
set -x FZF_DEFAULT_OPTS "--height=40% --layout=reverse --multi"
|
||||||
|
set -x FZF_DEFAULT_COMMAND "fd --type=file"
|
||||||
|
set -x FZF_CTRL_T_COMMAND "fd --type=file --follow"
|
||||||
|
set -x FZF_CTRL_T_OPTS "--ansi --no-height --preview 'bat --color=always {}'"
|
||||||
|
set -x FZF_CTRL_R_OPTS "--preview 'echo {}' --preview-window down:3:hidden:wrap --bind '?:toggle-preview'"
|
||||||
|
set -x FZF_ALT_C_COMMAND "fd --type=directory --follow"
|
||||||
|
set -x FZF_ALT_C_OPTS "--preview 'tree -C {} | head -200'"
|
||||||
|
|
||||||
|
# Git prompt
|
||||||
|
set -g __fish_git_prompt_showdirtystate 1
|
||||||
|
set -g __fish_git_prompt_showstashstate 1
|
||||||
|
set -g __fish_git_prompt_showuntrackedfiles 1
|
||||||
|
set -g __fish_git_prompt_showupstream 'informative'
|
||||||
|
set -g __fish_git_prompt_char_upstream_ahead '↑'
|
||||||
|
set -g __fish_git_prompt_char_upstream_behind '↓'
|
||||||
|
set -g __fish_git_prompt_char_upstream_prefix ' '
|
||||||
|
set -g __fish_git_prompt_color_branch magenta
|
||||||
|
set -g __fish_git_prompt_color_dirtystate cyan
|
||||||
|
set -g __fish_git_prompt_color_invalidstate red
|
||||||
|
set -g __fish_git_prompt_color_stagedstate cyan
|
||||||
|
set -g __fish_git_prompt_color_stashstate cyan
|
||||||
|
set -g __fish_git_prompt_color_untrackedfiles cyan
|
||||||
|
set -g __fish_git_prompt_color_upstream yellow
|
||||||
|
|
||||||
# Path
|
# Path
|
||||||
set --erase PATH
|
set --erase PATH
|
||||||
test -d $HOME/bin ; and set -x PATH $HOME/bin
|
test -d $HOME/bin ; and set -x PATH $HOME/bin
|
||||||
@ -24,24 +47,22 @@ test -d /usr/sbin ; and set -x PATH $PATH /usr/sbin
|
|||||||
test -d /sbin ; and set -x PATH $PATH /sbin
|
test -d /sbin ; and set -x PATH $PATH /sbin
|
||||||
|
|
||||||
# Aliases
|
# Aliases
|
||||||
alias adventure='emacs -batch -l dunnet'
|
|
||||||
alias afk='pmset displaysleepnow'
|
alias afk='pmset displaysleepnow'
|
||||||
alias md5sum="md5 -r $argv"
|
alias md5sum='md5 -r'
|
||||||
alias sha256sum="shasum -a 256 $argv"
|
alias sha256sum='shasum -a 256'
|
||||||
alias vi='nvim'
|
alias vi='nvim'
|
||||||
|
alias vim='nvim'
|
||||||
|
|
||||||
# Install package manager if needed
|
# Fish package manager
|
||||||
if not functions -q fisher
|
|
||||||
curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish
|
|
||||||
fish -c fisher
|
|
||||||
end
|
|
||||||
|
|
||||||
# Set package installation folder
|
|
||||||
set -g fisher_path ~/.config/fish/fisher
|
set -g fisher_path ~/.config/fish/fisher
|
||||||
|
|
||||||
# Add packages to fish config
|
|
||||||
set fish_function_path $fish_function_path[1] $fisher_path/functions $fish_function_path[2..-1]
|
set fish_function_path $fish_function_path[1] $fisher_path/functions $fish_function_path[2..-1]
|
||||||
set fish_complete_path $fish_complete_path[1] $fisher_path/completions $fish_complete_path[2..-1]
|
set fish_complete_path $fish_complete_path[1] $fisher_path/completions $fish_complete_path[2..-1]
|
||||||
for file in $fisher_path/conf.d/*.fish
|
for file in $fisher_path/conf.d/*.fish
|
||||||
builtin source $file 2> /dev/null
|
builtin source $file 2> /dev/null
|
||||||
end
|
end
|
||||||
|
if not functions -q fisher
|
||||||
|
echo "Installing fish-shell package manager: $fisher_path/functions/fisher.fish"
|
||||||
|
curl https://git.io/fisher --create-dirs -sLo $fisher_path/functions/fisher.fish
|
||||||
|
echo "Installing fish-shell packages..."
|
||||||
|
fish -c fisher
|
||||||
|
end
|
||||||
|
@ -1,2 +1,4 @@
|
|||||||
jorgebucaran/fish-bax
|
jorgebucaran/fish-bax
|
||||||
jorgebucaran/fish-nvm
|
jorgebucaran/fish-nvm
|
||||||
|
oh-my-fish/plugin-license
|
||||||
|
oh-my-fish/plugin-sublime
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
function _set_global_if_unset --argument-names variable_name variable_value
|
|
||||||
if not set --query $variable_name
|
|
||||||
set --global $variable_name $variable_value
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,15 +1,15 @@
|
|||||||
function battery
|
function battery
|
||||||
# Only works on Mac
|
# Only works on Mac
|
||||||
if test (uname -s) != Darwin
|
if test (uname -s) != Darwin
|
||||||
echo "Unsupported OS: "(uname -s)
|
echo "Unsupported OS: "(uname -s)
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
set --local battery_status (pmset -g batt | string split0)
|
set --local battery_status (pmset -g batt | string split0)
|
||||||
set --local battery_charge (echo $battery_status | rg --only-matching "\d+%")
|
set --local battery_charge (echo $battery_status | rg --only-matching "\d+%")
|
||||||
set --local power_source (echo $battery_status | rg --only-matching "[A-Za-z]+\sPower")
|
set --local power_source (echo $battery_status | rg --only-matching "[A-Za-z]+\sPower")
|
||||||
|
|
||||||
set_color green
|
set_color green
|
||||||
echo "⚡️ Running on $power_source with $battery_charge charge"
|
echo "⚡️ Running on $power_source with $battery_charge charge"
|
||||||
set_color normal
|
set_color normal
|
||||||
end
|
end
|
||||||
|
@ -1,12 +0,0 @@
|
|||||||
function brew_install --description "Select packages to install"
|
|
||||||
set --local inst_pkgs $argv
|
|
||||||
|
|
||||||
if test (count $inst_pkgs) -eq 0
|
|
||||||
set inst_pkgs (brew search | eval "fzf --multi --prompt='[brew:install] '")
|
|
||||||
end
|
|
||||||
|
|
||||||
if test (count $inst_pkgs) -gt 0
|
|
||||||
echo "Installing: $inst_pkgs"
|
|
||||||
brew install $inst_pkgs
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,49 +0,0 @@
|
|||||||
function brew_uninstall --description "Select packages to uninstall"
|
|
||||||
set --local uninst_pkgs $argv
|
|
||||||
|
|
||||||
if test (count $uninst_pkgs) -eq 0
|
|
||||||
set uninst_pkgs (brew leaves | eval "fzf --multi --prompt='[brew:uninstall] '")
|
|
||||||
end
|
|
||||||
|
|
||||||
if test (count $uninst_pkgs) -gt 0
|
|
||||||
echo "Determining package dependencies..."
|
|
||||||
|
|
||||||
# Output is multiline with format "pkgname:" if no dependencies, otherwise "pkgname: dep1 dep2 dep3 ..."
|
|
||||||
set --local brew_deps_installed (string collect (brew deps --installed))
|
|
||||||
|
|
||||||
# Accumulate uninst_pkgs and their transitive dependencies
|
|
||||||
set --local uninst_pkgs_all $uninst_pkgs
|
|
||||||
for bdi in $brew_deps_installed
|
|
||||||
set --local pkg (string split ':' $bdi | head -n 1)
|
|
||||||
set --local deps (string split ' ' (string split ':' $bdi | tail -n +2))
|
|
||||||
if contains -- $pkg $uninst_pkgs
|
|
||||||
for dep in $deps
|
|
||||||
if test -n $dep
|
|
||||||
if not contains -- $dep $uninst_pkgs_all
|
|
||||||
set uninst_pkgs_all $uninst_pkgs_all $dep
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
# Don't uninstall packages that are still dependencies of other packages
|
|
||||||
set --local uninst_pkgs_final $uninst_pkgs_all
|
|
||||||
for bdi in $brew_deps_installed
|
|
||||||
set --local pkg (string split ':' $bdi | head -n 1)
|
|
||||||
set --local deps (string split ' ' (string split ':' $bdi | tail -n +2))
|
|
||||||
if not contains -- $pkg $uninst_pkgs_all
|
|
||||||
for dep in $deps
|
|
||||||
if test -n $dep
|
|
||||||
if set --local index (contains --index $dep $uninst_pkgs_final)
|
|
||||||
set --erase uninst_pkgs_final[$index]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
echo "Uninstalling: $uninst_pkgs_final"
|
|
||||||
brew uninstall $uninst_pkgs_final
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,8 +1,8 @@
|
|||||||
function _confirmation --description "Ask for user confirmation"
|
function confirm --description "Ask for user confirmation"
|
||||||
while true
|
while true
|
||||||
read --local --prompt-str='Are you sure you want to continue? [y/N] ' confirm
|
read --local --prompt-str='Are you sure you want to continue? [y/N] ' confirmed
|
||||||
|
|
||||||
switch $confirm
|
switch $confirmed
|
||||||
case Y y
|
case Y y
|
||||||
return 0
|
return 0
|
||||||
case '' N n
|
case '' N n
|
@ -1,8 +1,8 @@
|
|||||||
function dns_flush
|
function dns_flush
|
||||||
switch (uname -s)
|
switch (uname -s)
|
||||||
case Darwin
|
case Darwin
|
||||||
sudo killall -HUP mDNSResponder
|
sudo killall -HUP mDNSResponder
|
||||||
case '*'
|
case '*'
|
||||||
echo "Unsupported OS: "(uname -s)
|
echo "Unsupported OS: "(uname -s)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
78
fish/functions/fbrew.fish
Normal file
78
fish/functions/fbrew.fish
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
function fbrew --description "Fuzzy homebrew"
|
||||||
|
if test (count $argv) -eq 0
|
||||||
|
echo "Usage: fbrew <install|uninstall>"
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
|
||||||
|
switch $argv[1]
|
||||||
|
case i install
|
||||||
|
_fbrew_install $argv[2..-1]
|
||||||
|
case u uninstall
|
||||||
|
_fbrew_uninstall $argv[2..-1]
|
||||||
|
case '*'
|
||||||
|
echo "Unsupported command: $argv[1]"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fbrew_install
|
||||||
|
set --local inst_pkgs $argv
|
||||||
|
|
||||||
|
if test (count $inst_pkgs) -eq 0
|
||||||
|
set inst_pkgs (brew search | eval "fzf --prompt='[brew:install] '")
|
||||||
|
end
|
||||||
|
|
||||||
|
if test (count $inst_pkgs) -gt 0
|
||||||
|
echo "Installing: $inst_pkgs"
|
||||||
|
brew install $inst_pkgs
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function _fbrew_uninstall
|
||||||
|
set --local uninst_pkgs $argv
|
||||||
|
|
||||||
|
if test (count $uninst_pkgs) -eq 0
|
||||||
|
set uninst_pkgs (brew leaves | eval "fzf --prompt='[brew:uninstall] '")
|
||||||
|
end
|
||||||
|
|
||||||
|
if test (count $uninst_pkgs) -gt 0
|
||||||
|
echo "Determining package dependencies..."
|
||||||
|
|
||||||
|
# Output is multiline with format "pkgname:" if no dependencies, otherwise "pkgname: dep1 dep2 dep3 ..."
|
||||||
|
set --local brew_deps_installed (string collect (brew deps --installed))
|
||||||
|
|
||||||
|
# Accumulate uninst_pkgs and their transitive dependencies
|
||||||
|
set --local uninst_pkgs_all $uninst_pkgs
|
||||||
|
for bdi in $brew_deps_installed
|
||||||
|
set --local pkg (string split ':' $bdi | head -n 1)
|
||||||
|
set --local deps (string split ' ' (string split ':' $bdi | tail -n +2))
|
||||||
|
if contains -- $pkg $uninst_pkgs
|
||||||
|
for dep in $deps
|
||||||
|
if test -n $dep
|
||||||
|
if not contains -- $dep $uninst_pkgs_all
|
||||||
|
set uninst_pkgs_all $uninst_pkgs_all $dep
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
# Don't uninstall packages that are still dependencies of other packages
|
||||||
|
set --local uninst_pkgs_final $uninst_pkgs_all
|
||||||
|
for bdi in $brew_deps_installed
|
||||||
|
set --local pkg (string split ':' $bdi | head -n 1)
|
||||||
|
set --local deps (string split ' ' (string split ':' $bdi | tail -n +2))
|
||||||
|
if not contains -- $pkg $uninst_pkgs_all
|
||||||
|
for dep in $deps
|
||||||
|
if test -n $dep
|
||||||
|
if set --local index (contains --index $dep $uninst_pkgs_final)
|
||||||
|
set --erase uninst_pkgs_final[$index]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
echo "Uninstalling: $uninst_pkgs_final"
|
||||||
|
brew uninstall $uninst_pkgs_final
|
||||||
|
end
|
||||||
|
end
|
@ -1,14 +1,13 @@
|
|||||||
function fish_prompt --description 'Write out the prompt'
|
function fish_prompt --description 'Write out the prompt'
|
||||||
# Save status code for previous command
|
# Save status code for previous command
|
||||||
set -l last_status $status
|
set -l last_status $status
|
||||||
|
|
||||||
# Print working directory
|
# Print working directory
|
||||||
set_color $fish_color_cwd
|
set_color $fish_color_cwd
|
||||||
echo -n (prompt_pwd)
|
echo -n (prompt_pwd)
|
||||||
set_color normal
|
set_color normal
|
||||||
|
|
||||||
# Print Git information
|
# Print git information
|
||||||
fish_prompt_git_settings
|
|
||||||
printf '%s ' (__fish_git_prompt)
|
printf '%s ' (__fish_git_prompt)
|
||||||
|
|
||||||
# Print status code for previous command, if nonzero
|
# Print status code for previous command, if nonzero
|
||||||
@ -18,6 +17,6 @@ function fish_prompt --description 'Write out the prompt'
|
|||||||
set_color normal
|
set_color normal
|
||||||
end
|
end
|
||||||
|
|
||||||
# Print the final character (§)
|
# Print the final character
|
||||||
echo -n "> "
|
echo -n "> "
|
||||||
end
|
end
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
function fish_prompt_git_settings --description 'Configure the git prompt'
|
|
||||||
# Toggles
|
|
||||||
_set_global_if_unset __fish_git_prompt_showdirtystate 1
|
|
||||||
_set_global_if_unset __fish_git_prompt_showstashstate 1
|
|
||||||
_set_global_if_unset __fish_git_prompt_showuntrackedfiles 1
|
|
||||||
_set_global_if_unset __fish_git_prompt_showupstream "informative"
|
|
||||||
|
|
||||||
# Characters
|
|
||||||
_set_global_if_unset __fish_git_prompt_char_upstream_ahead '↑'
|
|
||||||
_set_global_if_unset __fish_git_prompt_char_upstream_behind '↓'
|
|
||||||
_set_global_if_unset __fish_git_prompt_char_upstream_prefix ' '
|
|
||||||
|
|
||||||
# Colors
|
|
||||||
_set_global_if_unset __fish_git_prompt_color_branch magenta
|
|
||||||
_set_global_if_unset __fish_git_prompt_color_dirtystate cyan
|
|
||||||
_set_global_if_unset __fish_git_prompt_color_invalidstate red
|
|
||||||
_set_global_if_unset __fish_git_prompt_color_stagedstate cyan
|
|
||||||
_set_global_if_unset __fish_git_prompt_color_stashstate cyan
|
|
||||||
_set_global_if_unset __fish_git_prompt_color_untrackedfiles cyan
|
|
||||||
_set_global_if_unset __fish_git_prompt_color_upstream yellow
|
|
||||||
end
|
|
32
fish/functions/fkill.fish
Normal file
32
fish/functions/fkill.fish
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
function fkill --description "Fuzzy kill processes"
|
||||||
|
#
|
||||||
|
# Signal Numbers:
|
||||||
|
#
|
||||||
|
# 1 HUP (hang up)
|
||||||
|
# 2 INT (interrupt)
|
||||||
|
# 3 QUIT (quit)
|
||||||
|
# 6 ABRT (abort)
|
||||||
|
# 9 KILL (non-catchable, non-ignorable kill)
|
||||||
|
# 14 ALRM (alarm clock)
|
||||||
|
# 15 TERM (software termination signal)
|
||||||
|
#
|
||||||
|
|
||||||
|
set --local fkill_uid (id -u)
|
||||||
|
set --local fkill_pid
|
||||||
|
set --local fkill_procs
|
||||||
|
|
||||||
|
if contains -- '--tcp' $argv
|
||||||
|
set fkill_pid (lsof -Pwni tcp | sed 1d | eval "fzf --prompt='[kill:tcp] '" | awk '{print $2}')
|
||||||
|
else
|
||||||
|
if test $fkill_uid -eq 0
|
||||||
|
set fkill_procs (ps -ef | tail -n +2 | string collect)
|
||||||
|
else
|
||||||
|
set fkill_procs (ps -f -u $fkill_uid | tail -n +2 | string collect)
|
||||||
|
end
|
||||||
|
set fkill_pid (echo $fkill_procs | eval "fzf --prompt='[kill:process] ' --preview='ps -p {2}' --preview-window='down:3'" | awk '{print $2}')
|
||||||
|
end
|
||||||
|
|
||||||
|
if test (count $fkill_pid) -gt 0
|
||||||
|
echo $fkill_pid | xargs kill -9
|
||||||
|
end
|
||||||
|
end
|
@ -1,5 +1,5 @@
|
|||||||
function hr --description "Draw horizontal rule"
|
function hr --description "Draw horizontal rule"
|
||||||
set --local char '─'
|
set --local char '─'
|
||||||
printf "%.s$char" (seq $COLUMNS)
|
printf "%.s$char" (seq $COLUMNS)
|
||||||
echo
|
echo
|
||||||
end
|
end
|
||||||
|
3
fish/functions/jira.fish
Normal file
3
fish/functions/jira.fish
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
function jira
|
||||||
|
open "https://track.akamai.com/jira/browse/"$argv[1]
|
||||||
|
end
|
@ -1,21 +1,21 @@
|
|||||||
function jvm --argument-names __jvm_version
|
function jvm --argument-names __jvm_version
|
||||||
# Only works on Mac
|
# Only works on Mac
|
||||||
if test (uname -s) != Darwin
|
if test (uname -s) != Darwin
|
||||||
echo "Unsupported OS: "(uname -s)
|
echo "Unsupported OS: "(uname -s)
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
|
|
||||||
if test -z "$__jvm_version"
|
if test -z "$__jvm_version"
|
||||||
echo "Usage: jvm <java_version>"
|
echo "Usage: jvm <java_version>"
|
||||||
#echo
|
#echo
|
||||||
#/usr/libexec/java_home --verbose
|
#/usr/libexec/java_home --verbose
|
||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
|
|
||||||
set --local __jvm_homedir (/usr/libexec/java_home -v $__jvm_version)
|
set --local __jvm_homedir (/usr/libexec/java_home -v $__jvm_version)
|
||||||
|
|
||||||
if test $status -eq 0
|
if test $status -eq 0
|
||||||
echo "Setting JAVA_HOME to $__jvm_homedir"
|
echo "Setting JAVA_HOME to $__jvm_homedir"
|
||||||
set -gx JAVA_HOME $__jvm_homedir
|
set -gx JAVA_HOME $__jvm_homedir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,17 +0,0 @@
|
|||||||
function kp --description "Kill processes"
|
|
||||||
set --local __kp__pid ''
|
|
||||||
|
|
||||||
if contains -- '--tcp' $argv
|
|
||||||
set __kp__pid (lsof -Pwni tcp | sed 1d | eval "fzf --multi --prompt='[kill:tcp] '" | awk '{print $2}')
|
|
||||||
else
|
|
||||||
set __kp__pid (ps -ef | sed 1d | eval "fzf --multi --prompt='[kill:process] '" | awk '{print $2}')
|
|
||||||
end
|
|
||||||
|
|
||||||
if test "x$__kp__pid" != "x"
|
|
||||||
if test "x$argv[1]" != "x"
|
|
||||||
echo $__kp__pid | xargs kill $argv[1]
|
|
||||||
else
|
|
||||||
echo $__kp__pid | xargs kill -9
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
@ -1,11 +1,11 @@
|
|||||||
function motd --description "Message of the day!"
|
function motd --description "Message of the day!"
|
||||||
set --local daily_msg
|
set --local daily_msg
|
||||||
|
|
||||||
if contains -- '--chuck-norris' $argv
|
if contains -- '--chuck-norris' $argv
|
||||||
set daily_msg (curl -s 'https://api.chucknorris.io/jokes/random' | jq --raw-output '.value')
|
set daily_msg (curl -s 'https://api.chucknorris.io/jokes/random' | jq --raw-output '.value')
|
||||||
else
|
else
|
||||||
set daily_msg (fortune)
|
set daily_msg (fortune)
|
||||||
end
|
end
|
||||||
|
|
||||||
cowsay $daily_msg
|
cowsay $daily_msg
|
||||||
end
|
end
|
||||||
|
@ -1,13 +0,0 @@
|
|||||||
function path_search --description "Search your path for an executable"
|
|
||||||
set --local loc (echo $PATH | tr ' ' '\n' | eval "fzf --prompt='[find:path] '")
|
|
||||||
|
|
||||||
if test (count $loc) = 1
|
|
||||||
set --local cmd (rg --files -L $loc | rev | cut -d'/' -f1 | rev | tr ' ' '\n' | eval "fzf --preview='head -20 $loc/{}' --prompt='[find:exe] '")
|
|
||||||
if test (count $cmd) = 1
|
|
||||||
echo $cmd
|
|
||||||
else
|
|
||||||
path_search
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
function pip3_upgrade --description "Upgrade python packages (pip3)"
|
function pip_upgrade --description "Upgrade python packages"
|
||||||
set --local py_pkgs_outdated (pip3 list --outdated | awk 'NR > 2 {print $1}')
|
set --local py_pkgs_outdated (pip3 list --outdated | awk 'NR > 2 {print $1}')
|
||||||
|
|
||||||
if test (count $py_pkgs_outdated) = 0
|
if test (count $py_pkgs_outdated) = 0
|
||||||
|
7
fish/functions/port_listener.fish
Normal file
7
fish/functions/port_listener.fish
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
function port_listener --argument-names port
|
||||||
|
if test -n "$port"
|
||||||
|
lsof -n -i :$port | rg LISTEN
|
||||||
|
else
|
||||||
|
lsof -n -i | rg LISTEN
|
||||||
|
end
|
||||||
|
end
|
@ -1,7 +0,0 @@
|
|||||||
function portlistener --argument-names port
|
|
||||||
if test -n "$port"
|
|
||||||
lsof -n -i :$port | grep LISTEN
|
|
||||||
else
|
|
||||||
lsof -n -i | grep LISTEN
|
|
||||||
end
|
|
||||||
end
|
|
17
fish/functions/pull_request.fish
Normal file
17
fish/functions/pull_request.fish
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
function pull_request --argument-names target_branch source_branch
|
||||||
|
if test -z "$target_branch"
|
||||||
|
set target_branch (git symbolic-ref refs/remotes/origin/HEAD | sed 's@^refs/remotes/origin/@@')
|
||||||
|
echo "Using default branch as target: "$target_branch
|
||||||
|
end
|
||||||
|
if test -z "$source_branch"
|
||||||
|
set source_branch (git branch --show-current)
|
||||||
|
echo "Using current branch as source: "$source_branch
|
||||||
|
end
|
||||||
|
|
||||||
|
# Format: ssh://git@git.source.akamai.com:7999/<project>/<repo>.git
|
||||||
|
set --local origin (git remote get-url origin)
|
||||||
|
set --local project (string split -r -m2 '/' $origin)[-2]
|
||||||
|
set --local repo (basename -s .git $origin)
|
||||||
|
|
||||||
|
open "https://git.source.akamai.com/projects/"$project"/repos/"$repo"/compare/commits?sourceBranch=refs%2Fheads%2F"$source_branch"&targetBranch=refs%2Fheads%2F"$target_branch
|
||||||
|
end
|
@ -1,20 +1,20 @@
|
|||||||
function video_compress --argument-names srcfile
|
function video_compress --argument-names srcfile
|
||||||
if test -z "$srcfile"
|
if test -z "$srcfile"
|
||||||
echo "Error: missing argument"
|
echo "Error: missing argument"
|
||||||
return 1
|
return 1
|
||||||
end
|
end
|
||||||
if not test -f "$srcfile"
|
if not test -f "$srcfile"
|
||||||
echo "Error: not a regular file: $srcfile"
|
echo "Error: not a regular file: $srcfile"
|
||||||
return 2
|
return 2
|
||||||
end
|
end
|
||||||
if not command --search --quiet HandBrakeCLI
|
if not command --search --quiet HandBrakeCLI
|
||||||
echo "Error: HandBrakeCLI is required"
|
echo "Error: HandBrakeCLI is required"
|
||||||
return 3
|
return 3
|
||||||
end
|
end
|
||||||
|
|
||||||
# Output: srcfile.extension -> srcfile-compressed.mp4
|
# Output: srcfile.extension -> srcfile-compressed.mp4
|
||||||
set --local dstfile (string split -r -m1 . $srcfile)[1]-compressed.mp4
|
set --local dstfile (string split -r -m1 . $srcfile)[1]-compressed.mp4
|
||||||
set --local preset 'Vimeo YouTube HQ 720p60'
|
set --local preset 'Vimeo YouTube HQ 720p60'
|
||||||
|
|
||||||
HandBrakeCLI --preset $preset --input $srcfile --output $dstfile
|
HandBrakeCLI --preset $preset --input $srcfile --output $dstfile
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
function video_transfer
|
function video_transfer
|
||||||
for folder in (find ~/Pictures/GoPro -type d -mindepth 1 -maxdepth 1)
|
for folder in (find ~/Pictures/GoPro -type d -mindepth 1 -maxdepth 1)
|
||||||
mkdir -p ~/Movies/GoPro/$folder
|
mkdir -p ~/Movies/GoPro/$folder
|
||||||
pushd ~/Pictures/GoPro/$folder
|
pushd ~/Pictures/GoPro/$folder
|
||||||
fd --extension mp4 --exec mv -i -v "{}" ~/Movies/GoPro/$folder/"{/}"
|
fd --extension mp4 --exec mv -i -v "{}" ~/Movies/GoPro/$folder/"{/}"
|
||||||
popd
|
popd
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -29,7 +29,8 @@
|
|||||||
cand = commit --amend --no-edit --date=now
|
cand = commit --amend --no-edit --date=now
|
||||||
rbi = rebase --interactive
|
rbi = rebase --interactive
|
||||||
re = restore
|
re = restore
|
||||||
rh = reset HEAD
|
res = restore --staged
|
||||||
|
rh = reset -q HEAD --
|
||||||
[color]
|
[color]
|
||||||
ui = auto
|
ui = auto
|
||||||
[color "branch"]
|
[color "branch"]
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
DOTFILES="$HOME/.dotfiles"
|
DOTFILES="$HOME/dotfiles"
|
||||||
|
|
||||||
# Create required directories before making links
|
# Create required directories before making links
|
||||||
mkdir -p "$HOME/.config"
|
mkdir -p "$HOME/.config"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#!/bin/sh
|
#!/bin/sh
|
||||||
|
|
||||||
DOTFILES="$HOME/.dotfiles"
|
DOTFILES="$HOME/dotfiles"
|
||||||
|
|
||||||
# Install plugin manager for Neovim, if it doesn't exist
|
# Install plugin manager for Neovim, if it doesn't exist
|
||||||
VIM_PLUG_SRC="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
VIM_PLUG_SRC="https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim"
|
||||||
@ -15,7 +15,7 @@ grep -q /usr/local/bin/bash /etc/shells || echo /usr/local/bin/bash | sudo tee -
|
|||||||
grep -q /usr/local/bin/fish /etc/shells || echo /usr/local/bin/fish | sudo tee -a /etc/shells
|
grep -q /usr/local/bin/fish /etc/shells || echo /usr/local/bin/fish | sudo tee -a /etc/shells
|
||||||
|
|
||||||
# Make fish the default shell
|
# Make fish the default shell
|
||||||
chsh -s /usr/local/bin/fish
|
sudo chsh -s /usr/local/bin/fish `whoami`
|
||||||
|
|
||||||
# Install symlinks
|
# Install symlinks
|
||||||
"$DOTFILES/install-symlinks.sh"
|
"$DOTFILES/install-symlinks.sh"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user