From: Armaan Bhojwani <3fb650a9-b47e-4604-a282-1dd91953b2ee@anonaddy.me> Date: Wed, 16 Sep 2020 20:29:36 +0000 (-0400) Subject: new file structure X-Git-Url: https://git.armaanb.net/?p=charsel.git;a=commitdiff_plain;h=85a4c96299e44e38f7a1a8c9e38d863f29d9d111 new file structure --- diff --git a/INSTALL b/INSTALL new file mode 100755 index 0000000..c7eb02e --- /dev/null +++ b/INSTALL @@ -0,0 +1,24 @@ +#!/bin/env sh +# Make the folder in /tmp and make sure that it is writeable +mkdir /tmp/charsel/ +chmod 777 /tmp/charsel/ + +# Makes charsel executeable +chmod +x charsel + +# 2 sets of commands for whether it is root or not +if [ `whoami` == root ]; then + mkdir -p /usr/share/charsel/charfiles + cp charfiles/* /usr/share/charsel/charfiles/ + mkdir /usr/share/doc/charsel + cp README.md /usr/share/doc/charsel/ + cp src/motd /usr/share/charsel + cp src/charsel /usr/bin/ + exit +else + mkdir -p ~/.local/share/charsel/charfiles + cp charfiles/* ~/.local/share/charsel/charfiles + cp src/motd ~/.local/share/charsel/ + cp src/charsel ~/.local/bin/ + exit +fi diff --git a/INSTALL.sh b/INSTALL.sh deleted file mode 100755 index d883b14..0000000 --- a/INSTALL.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/env sh - -mkdir /tmp/charsel/ -chmod 777 /tmp/charsel/ -chmod +x charsel - -if [ `whoami` == root ]; then - mkdir -p /usr/share/charsel/charfiles - cp charfiles/* /usr/share/charsel/charfiles/ - mkdir /usr/share/doc/charsel - cp README.md /usr/share/doc/charsel/ - cp motd /usr/share/charsel - cp charsel /usr/bin/ - exit -else - mkdir -p ~/.local/share/charsel/charfiles - cp charfiles/* ~/.local/share/charsel/charfiles - cp motd ~/.local/share/charsel/ - cp charsel ~/.local/bin/ - exit -fi diff --git a/charsel b/charsel deleted file mode 100755 index b3dc786..0000000 --- a/charsel +++ /dev/null @@ -1,47 +0,0 @@ -#!/usr/bin/env sh -# Merge both global and local charfiles -CHARDIR=/tmp/charsel -cp -R /usr/share/charsel/* $CHARDIR/ -cp -R ~/.local/share/* $CHARDIR/ - -# Clear screen -clear - -# Check if user provided an input -[ -z "$1" ] && echo "No argument supplied" && exit - -if [ $1 = "list" ]; then - echo "The following charfiles are installed" - ls $CHARDIR/charfiles - exit -else - -# Define charfile -CHARFILE=$CHARDIR/charfiles/$1 - -# Define length of shortcut -LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1) - -# MOTD -cat /tmp/charsel/motd - -# Main program -while : -do - # Put charfile into table, showing only the shortcuts below the divider in the charfile - cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t --output-separator ' | ' --separator ',' - - # Automatically enter input - read -N $LENGTH INPUT - - # Navigate to the right characther - OUTPUT=$(grep $INPUT $CHARFILE | cut -f 2 -d ',' -s) - - # Clear screen - clear - - # Copy output to clipboard - echo $OUTPUT | xclip -selection clipboard -done - -fi diff --git a/motd b/motd deleted file mode 100644 index f95b67e..0000000 --- a/motd +++ /dev/null @@ -1,2 +0,0 @@ -WELCOME TO CHARSEL! -FOR HELP, PLEASE REFER TO /usr/share/doc/charsel/README.md diff --git a/src/charsel b/src/charsel new file mode 100755 index 0000000..b3dc786 --- /dev/null +++ b/src/charsel @@ -0,0 +1,47 @@ +#!/usr/bin/env sh +# Merge both global and local charfiles +CHARDIR=/tmp/charsel +cp -R /usr/share/charsel/* $CHARDIR/ +cp -R ~/.local/share/* $CHARDIR/ + +# Clear screen +clear + +# Check if user provided an input +[ -z "$1" ] && echo "No argument supplied" && exit + +if [ $1 = "list" ]; then + echo "The following charfiles are installed" + ls $CHARDIR/charfiles + exit +else + +# Define charfile +CHARFILE=$CHARDIR/charfiles/$1 + +# Define length of shortcut +LENGTH=$(cat $CHARFILE | cut -f 1 -d ',' -s | wc -L | cut -b 1) + +# MOTD +cat /tmp/charsel/motd + +# Main program +while : +do + # Put charfile into table, showing only the shortcuts below the divider in the charfile + cat $CHARFILE | grep -A 100 - | tail -n +2 | column -t --output-separator ' | ' --separator ',' + + # Automatically enter input + read -N $LENGTH INPUT + + # Navigate to the right characther + OUTPUT=$(grep $INPUT $CHARFILE | cut -f 2 -d ',' -s) + + # Clear screen + clear + + # Copy output to clipboard + echo $OUTPUT | xclip -selection clipboard +done + +fi diff --git a/src/motd b/src/motd new file mode 100644 index 0000000..f95b67e --- /dev/null +++ b/src/motd @@ -0,0 +1,2 @@ +WELCOME TO CHARSEL! +FOR HELP, PLEASE REFER TO /usr/share/doc/charsel/README.md