Skip to content

Commit

Permalink
Merge pull request #50 from jszczerbinsky/dev
Browse files Browse the repository at this point in the history
v0.3.1-beta
  • Loading branch information
jszczerbinsky authored Mar 27, 2022
2 parents 6ae7317 + 0bc47ca commit 8e24e97
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 36 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
*.out
*.o
*.a
build/
48 changes: 24 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,33 +1,33 @@
ver=/tmp/ptsh_ver

all:
@echo Run \'make install\'
mkdir -p build
rm -rf build/*
mkdir -p build/bin
mkdir -p build/share
mkdir -p build/share/ptSh
gcc src/common/*.c src/ptls/*.c -lm -o build/bin/ptls
gcc src/common/*.c src/ptpwd/*.c -lm -o build/bin/ptpwd
gcc src/common/*.c src/ptcp/*.c -lm -o build/bin/ptcp
cp src/ptsh.sh build/bin/ptsh
cp src/config build/share/ptSh/config
cp LICENSE build/share/ptSh/LICENSE
cp src/logo.txt build/share/ptSh/logo.txt
git rev-parse --short HEAD > /tmp/ptsh_ver
echo "Version: cloned from " | tee build/share/ptSh/version.txt
cat /tmp/ptsh_ver | tee -a build/share/ptSh/version.txt

install:
git rev-parse --short HEAD > $(ver)
mkdir -p ~/.local/share/ptSh
mkdir -p ~/.local/bin
mkdir -p build
gcc src/common/*.c src/ptls/*.c -lm -o build/ptls
gcc src/common/*.c src/ptpwd/*.c -lm -o build/ptpwd
gcc src/common/*.c src/ptcp/*.c -lm -o build/ptcp
cp build/* ~/.local/bin/
rm -rf build
cp src/config ~/.local/share/ptSh/config
cp LICENSE ~/.local/share/ptSh/LICENSE
cp src/logo.txt ~/.local/share/ptSh/logo.txt
cp src/ptsh.sh ~/.local/bin/ptsh
mkdir -p ~/.config
mkdir -p ~/.config/ptSh
sudo cp -R build/* /usr
mkdir -p ~/.config
mkdir -p ~/.config/ptSh
cp src/config ~/.config/ptSh/config
echo "Version: cloned from " | tee ~/.local/share/ptSh/version.txt
cat $(ver) | tee -a ~/.local/share/ptSh/version.txt
~/.local/bin/ptsh
/usr/bin/ptsh

uninstall:
rm -rf ~/.local/share/ptSh
sudo rm -rf /usr/share/ptSh
rm -rf ~/.config/ptSh
rm ~/.local/bin/ptls
rm ~/.local/bin/ptpwd
rm ~/.local/bin/ptmove
rm ~/.local/bin/ptsh
sudo rm /usr/bin/ptls
sudo rm /usr/bin/ptpwd
sudo rm /usr/bin/ptcp
sudo rm /usr/bin/ptsh
8 changes: 2 additions & 6 deletions src/common/configParser.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "configParser.h"

#define DEFAULT_CONFIG_PATH "/.local/share/ptSh/config"
#define DEFAULT_CONFIG_PATH "/usr/share/ptSh/config"
#define CONFIG_PATH "/.config/ptSh/config"

void setPattern(char** destination, char* line, const char* pattern)
Expand Down Expand Up @@ -123,18 +123,14 @@ PtShConfig *readConfig()
PtShConfig *config = (PtShConfig*)calloc(1, sizeof(PtShConfig));

char* homePath = getenv("HOME");
char* defaultPath = (char*)calloc(1,strlen(homePath) + strlen(DEFAULT_CONFIG_PATH) +1);
strcpy(defaultPath, homePath);
strcat(defaultPath, DEFAULT_CONFIG_PATH);

char* path = (char*)calloc(1,strlen(homePath) + strlen(CONFIG_PATH) +1);
strcpy(path, homePath);
strcat(path, CONFIG_PATH);

readData(config, defaultPath);
readData(config, DEFAULT_CONFIG_PATH);
readData(config, path);

free(defaultPath);
free(path);

return config;
Expand Down
9 changes: 9 additions & 0 deletions src/common/limits.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#if defined(__linux__)
#include <linux/limits.h>
#elif defined(__NetBSD__)
#include <limits.h>
#elif defined(_APPLE__)
#include <sys/syslimits.h>
#else
#include <limits.h>
#endif
2 changes: 1 addition & 1 deletion src/config
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# This is ptSh config file
# You can find default config file in ~/.local/share/ptSh/config
# You can find default config file in /usr/share/ptSh/config
# You should not override default config file
# Path to your config file should be /home/$USER/.config/ptSh/config

Expand Down
2 changes: 1 addition & 1 deletion src/ptls/fields.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ void setPermissions(Fields *fields, File *file, Args *args)
noGroupDecrease = 4;

char *permStr = calloc(12-noGroupDecrease, sizeof(char));
__mode_t mode = file->stats->st_mode;
mode_t mode = file->stats->st_mode;

permStr[0] = (mode & S_IRUSR) ? 'r' : '-';
permStr[1] = (mode & S_IWUSR) ? 'w' : '-';
Expand Down
2 changes: 1 addition & 1 deletion src/ptls/files.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#include <dirent.h>
#include <string.h>
#include <sys/stat.h>
#include <linux/limits.h>
#include "ptls.h"
#include "../common/limits.h"

DirContent *getFiles(Args *args)
{
Expand Down
6 changes: 3 additions & 3 deletions src/ptsh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,20 @@

echo -e "\x1B[35m"

cat ~/.local/share/ptSh/logo.txt
cat /usr/share/ptSh/logo.txt

echo "Let your shell commands look prettier..."
echo -e "\x1B[0m"

echo
while read -r line; do
echo -n "$line "
done <<<$(cat ~/.local/share/ptSh/version.txt)
done <<<$(cat /usr/share/ptSh/version.txt)

echo
echo

echo -e "If You enjoy ptSh, give it a \x1B[5m\x1B[93mstar\x1B[0m on github: \x1B[92mhttps://github.com/jszczerbinsky/ptSh\x1B[0m"
echo -e "\x1B[34m"
cat ~/.local/share/ptSh/LICENSE
cat /usr/share/ptSh/LICENSE
echo -e "\x1B[0m"

0 comments on commit 8e24e97

Please sign in to comment.