From 649a47da959e7ca636c2fb8f27b58739cead335b Mon Sep 17 00:00:00 2001 From: Syndamia Date: Sat, 30 Nov 2024 10:18:54 +0200 Subject: chore(bash): Reorganise certain stuff --- .bashrc | 84 ++++++++++++++++++++++++++++++++++------------------------------- 1 file changed, 44 insertions(+), 40 deletions(-) diff --git a/.bashrc b/.bashrc index bc1b2d2..34c4e38 100644 --- a/.bashrc +++ b/.bashrc @@ -269,18 +269,57 @@ EOF fg() { builtin fg >/dev/null } - alias fg="fg" + + # Run in the background + bgr() { + nohup sh -c "$@" >~/nohup.out 2>&1 & + disown + } + + # Kill process and run in the background + res() { + pkill $@ + bgr $@ + } + + # Launch .desktop application (either full path or just name) + dela() { + name=$1 + if [[ ${name:0:1} != "/" ]]; then + name="/usr/share/applications/${name}" + fi + if [[ ! $name =~ .desktop$ ]]; then + name+=".desktop" + fi + comm=($(awk -F= '$1=="Exec"{$1=""; print}' "$name")) + bgr "$comm" + } # }}} # Variables {{{ export NIX_SHELL_PRESERVE_PROMPT=1 # }}} -bind '"\C-l":clear-screen' +# File operations {{{ + cp() { + command cp -p $@ + } + + metas() { + for file in *; do + [ "$file" != 'cover.jpeg' ] && \ + kid3-cli -c "set title \"$(echo "$file" | sed -e "s/\.[^.]*$//")\"" \ + -c "set artist \"$1\"" -c "set album \"$2\"" -c "set date \"$3\"" \ + -c 'set picture:"./cover.jpeg" ""' "$file" \ + || : + done + } +# }}} + +# Bindings {{{ + bind '"\C-l":clear-screen' +# }}} -cp() { - command cp -p $@ -} if [ -n "$ZSHRC_FUNTOO" ] then @@ -325,18 +364,6 @@ fi # zle -N plumb-store-cwd # bindkey "^[[5;7~" plumb-store-cwd -# Run in the background -bgr() { - nohup sh -c "$@" >~/nohup.out 2>&1 & - disown -} - -# Kill process and run in the background -res() { - pkill $@ - bgr $@ -} - # Open vim with .vim-session file, if it exists and the vim command doesn't have any parameters v() { if [ -f ".vim-session" ] && [ -z "$1" ]; then @@ -357,29 +384,6 @@ onemo() { bgr "nemo ./" } -# Launch .desktop application (either full path or just name) -dela() { - name=$1 - if [[ ${name:0:1} != "/" ]]; then - name="/usr/share/applications/${name}" - fi - if [[ ! $name =~ .desktop$ ]]; then - name+=".desktop" - fi - comm=($(awk -F= '$1=="Exec"{$1=""; print}' "$name")) - bgr "$comm" -} - -metas() { - for file in *; do - [ "$file" != 'cover.jpeg' ] && \ - kid3-cli -c "set title \"$(echo "$file" | sed -e "s/\.[^.]*$//")\"" \ - -c "set artist \"$1\"" -c "set album \"$2\"" -c "set date \"$3\"" \ - -c 'set picture:"./cover.jpeg" ""' "$file" \ - || : - done -} - # # Aliases # -- cgit v1.2.3