fish: add kp (kill process) function, other tweaks

This commit is contained in:
Charles Gould 2019-09-19 00:29:09 -04:00
parent 03ec1fcc30
commit 89689156e2
6 changed files with 36 additions and 4 deletions

View File

@ -8,6 +8,8 @@ set fish_prompt_pwd_dir_length 0
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 --hidden --follow --exclude .git'
set -x FZF_DEFAULT_OPTS '--height 40%'
# Java environment # Java environment
set JAVA_HOME_8 (/usr/libexec/java_home -v 1.8) set JAVA_HOME_8 (/usr/libexec/java_home -v 1.8)
@ -30,4 +32,5 @@ alias afk='pmset displaysleepnow'
alias java8="set -gx JAVA_HOME $JAVA_HOME_8" alias java8="set -gx JAVA_HOME $JAVA_HOME_8"
alias java11="set -gx JAVA_HOME $JAVA_HOME_11" alias java11="set -gx JAVA_HOME $JAVA_HOME_11"
alias md5sum="md5 -r $argv" alias md5sum="md5 -r $argv"
alias sha256sum="shasum -a 256 $argv"
alias vi='nvim' alias vi='nvim'

View File

@ -12,11 +12,9 @@ function compress_video --argument-names srcfile
return 3 return 3
end end
set --local dstdir (dirname $srcfile)/Compressed # Output: srcfile.extension -> srcfile-compressed.mp4
set --local dstfile (dirname $srcfile)/Compressed/(basename $srcfile) 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'
mkdir -p $dstdir
HandBrakeCLI --preset $preset --input $srcfile --output $dstfile HandBrakeCLI --preset $preset --input $srcfile --output $dstfile
end end

18
fish/functions/kp.fish Normal file
View File

@ -0,0 +1,18 @@
function kp --description "Kill processes"
set --local __kp__pid ''
if contains -- '--tcp' $argv
set __kp__pid (lsof -Pwni tcp | sed 1d | eval "fzf $FZF_DEFAULT_OPTS -m --header='[kill:tcp]'" | awk '{print $2}')
else
set __kp__pid (ps -ef | sed 1d | eval "fzf $FZF_DEFAULT_OPTS -m --header='[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
kp
end
end

View File

@ -0,0 +1,8 @@
function move_videos
for folder in (find ~/Pictures/GoPro -type d -mindepth 1 -maxdepth 1)
mkdir -p ~/Movies/GoPro/$folder
pushd ~/Pictures/GoPro/$folder
fd --extension mp4 --exec mv -i -v "{}" ~/Movies/GoPro/$folder/"{/}"
popd
end
end

View File

@ -15,6 +15,7 @@
lol = log --oneline --max-count=10 --decorate=no lol = log --oneline --max-count=10 --decorate=no
ss = status --short ss = status --short
st = status --long st = status --long
sw = switch
cp = cherry-pick cp = cherry-pick
f = fetch --all --prune f = fetch --all --prune
pl = pull pl = pull
@ -27,6 +28,7 @@
can = commit --amend --no-edit can = commit --amend --no-edit
cand = commit --amend --no-edit --date=now cand = commit --amend --no-edit --date=now
rbi = rebase --interactive rbi = rebase --interactive
re = restore
rh = reset HEAD rh = reset HEAD
[color] [color]
ui = auto ui = auto

View File

@ -17,6 +17,9 @@ call plug#end()
set nonumber norelativenumber " show hybrid line numbers at startup set nonumber norelativenumber " show hybrid line numbers at startup
noremap <F2> :set number! relativenumber!<CR> " toggle line numbers noremap <F2> :set number! relativenumber!<CR> " toggle line numbers
" Disable match highlighting
let g:loaded_matchparen=1
" write settings " write settings
set confirm " confirm :q in case of unsaved changes set confirm " confirm :q in case of unsaved changes