Browse Source

Added

* TS[X] to js[x] transpiler
* touchp like mkdirp
* command to change size of waydroid container
* Restart pulseaudio
* Convert video for mobile phones
* change selinux context of directory so that docker can access those files
* Start a Developer session in current directory
* Clone a git repo using given ssh key
pull/19/head
Harish Karumuthil 2 years ago
parent
commit
6687da63a1
  1. 88
      home/.local/Apps/daily-utils/bin/hari-tools.sh
  2. 37
      home/.local/Apps/daily-utils/install-data-utils.sh
  3. 2
      home/.tmux.conf

88
home/.local/Apps/daily-utils/bin/hari-tools.sh

@ -12,6 +12,74 @@ list-commands(){
typeset -F | cut -d ' ' -f 3 | grep -v '^_' | sort typeset -F | cut -d ' ' -f 3 | grep -v '^_' | sort
} }
# ts / tsx to js/jsx
tstojs(){
set -x
tsc --jsx preserve -t es2020 --outDir js --noEmit false $@
}
# cmd </long/file/path.ext> Create file by creating all parents
touchp(){
local fname="$1"
local parentDir=$(dirname "$fname")
mkdir -p "$parentDir"
touch "$fname"
}
# cmd <width> <height>. Change waydroid size and restart session
waydroidChangeSize(){
local width=$1
local height=$2
waydroid prop set persist.waydroid.width $width
waydroid prop set persist.waydroid.height $height
waydroid session stop
waydroid session start &
sleep 1
waydroid show-full-ui
}
# Restart pulseaudio
pulseAudioRestart(){
set -x
systemctl --user restart pipewire-pulse
}
# Convert video to mp4 for mobile device. videoformobile <infile> [opts...]
videoformobile(){
local infile=$1;
shift
set -x
ffmpeg -i "$infile" -c:v libx264 -pix_fmt yuv420p -profile:v baseline -level 3.0 $@
}
# allow permission for docker container. dockerAllow <path>
dockerAllow(){
set -x
chcon -R system_u:object_r:container_file_t:s0 "$1"
}
# Start development env in current directory
devSetup(){
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Switch One Desktop to the Right"
lvim &
bash-session -n &
sleep 1.5
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Window Maximize"
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Walk Through Windows"
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Window Maximize"
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Switch One Desktop Down"
git gui &
sleep 1.5
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Window Maximize"
qdbus org.kde.kglobalaccel /component/kwin invokeShortcut "Switch One Desktop Up"
}
# cd to npm home
npmHome(){
cd ~/.node_modules_mine;
bash-session
}
# cmd <inputfile> .csv to json using miller cli # cmd <inputfile> .csv to json using miller cli
csvToJson(){ csvToJson(){
mlr --c2j --jlistwrap cat "$1" mlr --c2j --jlistwrap cat "$1"
@ -39,7 +107,7 @@ ocr(){
} }
# resize pdf <input> <output> # resize pdf <input> <output>
resizePdf(){
pdfResize(){
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dDownsampleColorImages=true -dColorImageResolution=94 -dNOPAUSE -dBATCH -sOutputFile="$2" "$1" gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dDownsampleColorImages=true -dColorImageResolution=94 -dNOPAUSE -dBATCH -sOutputFile="$2" "$1"
} }
@ -68,6 +136,7 @@ clearSysRq(){
# Print current public ip using ipify API # Print current public ip using ipify API
myIp(){ myIp(){
set -x
curl 'https://api.ipify.org?format=json' curl 'https://api.ipify.org?format=json'
} }
@ -202,6 +271,23 @@ kwinCompositorReload(){
qdbus-qt5 org.kde.KWin /Compositor resume qdbus-qt5 org.kde.KWin /Compositor resume
} }
# Clone git with custom key
# gitclone <url> [ssh_key_path]
gitClone(){
set -x
local url="$1"
shift
local sshkey="$1"
if [[ -n "$sshkey" ]]; then
export GIT_SSH_COMMAND="ssh -i '$sshkey'"
fi
targetDir=$(basename "$url")
targetDir=${targetDir/.git/}
git clone "$url" "$targetDir"
cd "$targetDir"
git config core.sshCommand "$GIT_SSH_COMMAND"
}
# format cookies copied from chrome cookie table # format cookies copied from chrome cookie table
# Usage cat file | formatChromeCookie domain.com # Usage cat file | formatChromeCookie domain.com
formatChromeCookie(){ formatChromeCookie(){

37
home/.local/Apps/daily-utils/install-data-utils.sh

@ -0,0 +1,37 @@
#!/usr/bin/env bash
# Download following
# 1. https://github.com/cube2222/octosql
# 2. https://github.com/TomWright/dasel
# 3. https://github.com/multiprocessio/dsq
# 4. https://github.com/roapi/roapi
# 5. https://github.com/dcmoura/spyql
Projects=(
https://github.com/cube2222/octosql
https://github.com/TomWright/dasel
https://github.com/multiprocessio/dsq
https://github.com/roapi/roapi
https://github.com/dcmoura/spyql
)
getTarball(){
local projUrl=$1
local githubRepo=$(echo $projUrl | sed 's#https://github.com/##g')
local tarballs=$(curl -s "https://api.github.com/repos/$githubRepo/releases/latest" | grep 'browser_download_url.*gz' | grep -E 'amd64|x86_64' | grep linux | cut -d'"' -f4)
echo $tarballs
}
downloadPkg(){
local projUrl=$1
latestTarball=$(getTarball "$projUrl")
echo wget -c "$latestTarball"
}
main(){
for projUrl in ${Projects[@]} ; do
downloadPkg "$projUrl"
done
}
main

2
home/.tmux.conf

@ -1,3 +1,5 @@
set-option -g default-terminal 'tmux-256color'
set-option -ga terminal-overrides ',xterm-256color:Tc'
setw -g mode-keys vi setw -g mode-keys vi
set-option -g mouse on set-option -g mouse on
bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xsel -i --clipboard" bind-key -T copy-mode-vi MouseDragEnd1Pane send-keys -X copy-pipe-and-cancel "xsel -i --clipboard"

Loading…
Cancel
Save