From d55fb6b620bb911c00ce51b191351f8ac2805cc6 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Wed, 21 Sep 2022 15:45:30 +0300 Subject: [PATCH 01/10] Delete unnecessary code --- .bash_aliases | 9 --------- auto_mount.md | 12 ------------ mount_d_drive | 12 ------------ 3 files changed, 33 deletions(-) delete mode 100644 auto_mount.md delete mode 100755 mount_d_drive diff --git a/.bash_aliases b/.bash_aliases index ac11de4..cc4bc3f 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -1,21 +1,12 @@ -# launch Ghidra -alias ghidra='~/Apps/ghidra/ghidraRun' - # take a nap (suspend the system) alias nap='systemctl suspend' -# launch apktool -alias apktool='java -jar ~/Apps/apktool/apktool.jar' - # lanuch pwninit with a custom template alias pwninit='~/Apps/pwninit/pwninit --template-path ~/.config/pwninit-template.py' # get sorted disk usage for current working directory alias gdu='du -shl * | sort -h' -# start firefox -alias ffp='firefox -private-window &' - # delete branches no longer on remote # from: https://stackoverflow.com/questions/7726949/remove-tracking-branches-no-longer-on-remote alias gitlodel='git fetch -p && for branch in $(git for-each-ref --format '\''%(refname) %(upstream:track)'\'' refs/heads | awk '\''$2 == "[gone]" {sub("refs/heads/", "", $1); print $1}'\''); do git branch -D $branch; done' diff --git a/auto_mount.md b/auto_mount.md deleted file mode 100644 index 82f1c5c..0000000 --- a/auto_mount.md +++ /dev/null @@ -1,12 +0,0 @@ -# Mount my drive on boot -``` -UUID=01D6E903EBEC3D70 /media/D auto nodev,x-gvfs-show,remove_hiberfile 0 0 -``` -### Mount the drive when booting: -```shell -sudo vim /etc/fstab -# at the bottom of the file, add the entry above -# now to test that the configuration works, run: -sudo mount -a -# if you see no errors, the fstab entry is correct and you're safe to reboot -``` diff --git a/mount_d_drive b/mount_d_drive deleted file mode 100755 index 5b105b7..0000000 --- a/mount_d_drive +++ /dev/null @@ -1,12 +0,0 @@ -#!/bin/bash - -# Mount the D drive - -MOUNT_POINT="/media/D" - -if [ ! -d "$MOUNT_POINT" ]; then - sudo mkdir "$MOUNT_POINT" -fi - -# Warning!! this will destroy any unsaved data that is in the hibernated Windows session -sudo ntfs-3g -o remove_hiberfile /dev/sdb1 "$MOUNT_POINT" From 58715e5aab525e81a91ac3ea90551befaa69a822 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Wed, 21 Sep 2022 15:55:51 +0300 Subject: [PATCH 02/10] Set default .bashrc --- .bashrc | 146 ++++++++------------------------------------------------ 1 file changed, 21 insertions(+), 125 deletions(-) diff --git a/.bashrc b/.bashrc index 2f1fe3f..ad4581e 100644 --- a/.bashrc +++ b/.bashrc @@ -1,131 +1,27 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples +# .bashrc -# If not running interactively, don't do anything -case $- in - *i*) ;; - *) return;; -esac - -# don't put duplicate lines or lines starting with space in the history. -# See bash(1) for more options -HISTCONTROL=ignoreboth - -# append to the history file, don't overwrite it -shopt -s histappend - -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# If set, the pattern "**" used in a pathname expansion context will -# match all files and zero or more directories and subdirectories. -#shopt -s globstar - -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "${debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) +# Source global definitions +if [ -f /etc/bashrc ]; then + . /etc/bashrc fi -# set a fancy prompt (non-color, unless we know we "want" color) -case "$TERM" in - xterm-color|*-256color) color_prompt=yes;; -esac - -# uncomment for a colored prompt, if the terminal has the capability; turned -# off by default to not distract the user: the focus in a terminal window -# should be on the output of commands, not on the prompt -#force_color_prompt=yes - -if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes - else - color_prompt= - fi -fi - -if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' -else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' +# User specific environment +if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]] +then + PATH="$HOME/.local/bin:$HOME/bin:$PATH" fi -unset color_prompt force_color_prompt - -# If this is an xterm set the title to user@host:dir -case "$TERM" in -xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) - ;; -esac - -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - alias dir='dir --color=auto' - alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# colored GCC warnings and errors -#export GCC_COLORS='error=01;31:warning=01;35:note=01;36:caret=01;32:locus=01:quote=01' - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Add an "alert" alias for long running commands. Use like so: -# sleep 10; alert -alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"' - -# Alias definitions. -# You may want to put all your additions into a separate file like -# ~/.bash_aliases, instead of adding them here directly. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. - -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi - -# enable programmable completion features (you don't need to enable -# this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). -if ! shopt -oq posix; then - if [ -f /usr/share/bash-completion/bash_completion ]; then - . /usr/share/bash-completion/bash_completion - elif [ -f /etc/bash_completion ]; then - . /etc/bash_completion - fi -fi - -# ===== Extra Paths ===== -export PATH="$HOME/dev/pwn.kr/COMMANDS:$PATH" -# added my Scripts to PATH -export PATH="$HOME/Scripts:$PATH" -export PATH="$HOME/Scripts/secrets:$PATH" - -# ===== Source Custom Functions ===== -if [ -f ~/.bash_functions ]; then - . ~/.bash_functions +export PATH + +# Uncomment the following line if you don't like systemctl's auto-paging feature: +# export SYSTEMD_PAGER= + +# User specific aliases and functions +if [ -d ~/.bashrc.d ]; then + for rc in ~/.bashrc.d/*; do + if [ -f "$rc" ]; then + . "$rc" + fi + done fi -# ===== Default Programs ===== -export EDITOR="vim" +unset rc From 4b35f1cd263cb4e856995e03a61e61f4acdcbc8b Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Wed, 21 Sep 2022 16:01:51 +0300 Subject: [PATCH 03/10] Source .bash_aliases and .bash_functions --- .bashrc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/.bashrc b/.bashrc index ad4581e..3ca7661 100644 --- a/.bashrc +++ b/.bashrc @@ -15,6 +15,11 @@ export PATH # Uncomment the following line if you don't like systemctl's auto-paging feature: # export SYSTEMD_PAGER= +# Alias definitions +if [ -f ~/.bash_aliases ]; then + . ~/.bash_aliases +fi + # User specific aliases and functions if [ -d ~/.bashrc.d ]; then for rc in ~/.bashrc.d/*; do @@ -25,3 +30,11 @@ if [ -d ~/.bashrc.d ]; then fi unset rc + +# Extra Paths +export PATH="$HOME/.config/scripts:$PATH" + +# Source Custom Functions +if [ -f ~/.bash_functions ]; then + . ~/.bash_functions +fi \ No newline at end of file From 267fc33409bd833c8b3ec72fc6739e1870ed6590 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Wed, 21 Sep 2022 16:22:21 +0300 Subject: [PATCH 04/10] Delete use of .bashrc.d --- .bashrc | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.bashrc b/.bashrc index 3ca7661..c962dfa 100644 --- a/.bashrc +++ b/.bashrc @@ -20,17 +20,6 @@ if [ -f ~/.bash_aliases ]; then . ~/.bash_aliases fi -# User specific aliases and functions -if [ -d ~/.bashrc.d ]; then - for rc in ~/.bashrc.d/*; do - if [ -f "$rc" ]; then - . "$rc" - fi - done -fi - -unset rc - # Extra Paths export PATH="$HOME/.config/scripts:$PATH" From 60f7e3852ce7a14e42778c7c8a4ff3f98af16994 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Wed, 21 Sep 2022 16:55:36 +0300 Subject: [PATCH 05/10] Add colored prompt --- .bashrc | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.bashrc b/.bashrc index c962dfa..40db18f 100644 --- a/.bashrc +++ b/.bashrc @@ -5,6 +5,12 @@ if [ -f /etc/bashrc ]; then . /etc/bashrc fi +# Colored prompt +# [user@host:~ ]$ +# PS1='${debian_chroot:+($debian_chroot)}[\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\] ]\$ ' +# user@host:~$ +PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' + # User specific environment if ! [[ "$PATH" =~ "$HOME/.local/bin:$HOME/bin:" ]] then From b37cfa3d4d2815a8c638ac0e336443c3907ea910 Mon Sep 17 00:00:00 2001 From: Tommy Date: Wed, 19 Oct 2022 20:33:36 +0300 Subject: [PATCH 06/10] Aliases to nvim --- .bash_aliases | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.bash_aliases b/.bash_aliases index cc4bc3f..f091b1c 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -13,3 +13,8 @@ alias gitlodel='git fetch -p && for branch in $(git for-each-ref --format '\''%( # remove tracking branches no longer on remote alias gitredel='git remote prune origin' + +# nvim +alias vim="nvim" +alias vi="nvim" +alias v="nvim" \ No newline at end of file From 9487017082ce506c83990bb163d99dd2f77daad1 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Fri, 27 Sep 2024 20:54:50 +0300 Subject: [PATCH 07/10] Remove unused files --- biuftp | 4 ---- biussh | 4 ---- 2 files changed, 8 deletions(-) delete mode 100755 biuftp delete mode 100755 biussh diff --git a/biuftp b/biuftp deleted file mode 100755 index a5a22d8..0000000 --- a/biuftp +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# import username from secrets.sh and open a sftp connection -source "secrets.sh" && sftp -J $biu_username@vpn.esc.biu.ac.il:2222 $biu_username@planet.cs.biu.ac.il diff --git a/biussh b/biussh deleted file mode 100755 index 7473b1b..0000000 --- a/biussh +++ /dev/null @@ -1,4 +0,0 @@ -#!/bin/bash - -# import username from secrets.sh and open a ssh connection -source "secrets.sh" && ssh -J $biu_username@vpn.esc.biu.ac.il:2222 $biu_username@planet.cs.biu.ac.il From ac36cfa6fde158382a037c7f845c6c3ffd56df90 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Fri, 27 Sep 2024 21:03:21 +0300 Subject: [PATCH 08/10] Import aliases from master branch --- .bash_aliases | 10 +++++++++- .bashrc | 6 +++++- README.md | 1 + 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.bash_aliases b/.bash_aliases index f091b1c..fedb5ae 100644 --- a/.bash_aliases +++ b/.bash_aliases @@ -17,4 +17,12 @@ alias gitredel='git remote prune origin' # nvim alias vim="nvim" alias vi="nvim" -alias v="nvim" \ No newline at end of file +alias v="nvim" + +# Python +alias p="python3" +alias py="python3" +alias py2="python2" + +# Search for a directory and cd into it +alias sd='cd $(find ~ -type d | fzf)' diff --git a/.bashrc b/.bashrc index 40db18f..2483f98 100644 --- a/.bashrc +++ b/.bashrc @@ -32,4 +32,8 @@ export PATH="$HOME/.config/scripts:$PATH" # Source Custom Functions if [ -f ~/.bash_functions ]; then . ~/.bash_functions -fi \ No newline at end of file +fi + +# ===== Default Programs ===== +export EDITOR="vim" +export PAGER="less" diff --git a/README.md b/README.md index bc6dced..3d0f37c 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,3 @@ # Scripts + Some bash scripts I use for handling my linux machine. Nothing Fancy here :) From f2ba662f97f10b5ee40e63835cfd94f0e2f83793 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Fri, 21 Feb 2025 17:42:01 +0200 Subject: [PATCH 09/10] Create .window_bindings for toggling apps --- .window_bindings | 82 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100755 .window_bindings diff --git a/.window_bindings b/.window_bindings new file mode 100755 index 0000000..7adc11c --- /dev/null +++ b/.window_bindings @@ -0,0 +1,82 @@ +#!/bin/sh + +# Note that there's a known bug with Wayland, which sometimes doesn't display all windows (like GNOME apps): +# https://bugs.launchpad.net/ubuntu/+source/gnome-terminal/+bug/1725991 +# Recommended to switch to Xorg if you encounter this issue. + +toggle_brave() { + # If Brave is running, focus it. Otherwise, open it. + # If the --incognito flag is set, do the same for a private window. + INCOGNITO_MAGIC_STRING='Private Tab' + if [[ "$1" == '--incognito' ]]; then + # The window title for incognito windows is postfixed with 'Private Tab' when using my extension + WINDOW_ID=$(wmctrl -l | grep -F -- "$INCOGNITO_MAGIC_STRING - Brave" | awk '{print $1}') + if [ -n "$WINDOW_ID" ]; then + wmctrl -i -a "$WINDOW_ID" + else + brave-browser --incognito & + fi + else + WINDOW_ID=$(wmctrl -l | grep -Fv -- "$INCOGNITO_MAGIC_STRING - Brave" | grep -F -- '- Brave' | awk '{print $1}') + if [ -n "$WINDOW_ID" ]; then + wmctrl -i -a "$WINDOW_ID" + else + brave-browser & + fi + fi +} + +toggle_obsidian() { + # If Obsidian is running, focus it. Otherwise, open it. + if wmctrl -l | grep -q "Obsidian"; then + wmctrl -xa "obsidian.obsidian" + else + ~/Apps/obsidian/Obsidian.AppImage & + fi +} + +toggle_generic_app() { + # If the app is running, focus it. Otherwise, open it. + if wmctrl -lx | grep -iq "$1"; then + wmctrl -xa "$2" + else + $1 & + fi +} + +toggle_terminal() { + toggle_generic_app "gnome-terminal" "gnome.Terminal.Gnome-terminal" +} + +toggle_vscode() { + toggle_generic_app "code" "code.Code" +} + +toggle_file_manager() { + toggle_generic_app "nautilus" "org.gnome.Nautilus" +} + +# Handle supplied argument +case "$1" in + brave) + toggle_brave + ;; + brave-incognito) + toggle_brave --incognito + ;; + obsidian) + toggle_obsidian + ;; + terminal) + toggle_terminal + ;; + vscode) + toggle_vscode + ;; + files) + toggle_file_manager + ;; + *) + echo "Invalid option. Use: brave, brave-incognito, obsidian, terminal, vscode, files" + ;; +esac From 1bf0e37835731b4a61796fa842d927791557de84 Mon Sep 17 00:00:00 2001 From: Tommy <76645845+Tom-stack3@users.noreply.github.com> Date: Sat, 22 Feb 2025 13:57:18 +0200 Subject: [PATCH 10/10] Update --- .bashrc | 2 +- init.sh | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100755 init.sh diff --git a/.bashrc b/.bashrc index 2483f98..0b53957 100644 --- a/.bashrc +++ b/.bashrc @@ -35,5 +35,5 @@ if [ -f ~/.bash_functions ]; then fi # ===== Default Programs ===== -export EDITOR="vim" +export EDITOR="nvim" export PAGER="less" diff --git a/init.sh b/init.sh new file mode 100755 index 0000000..12a86e8 --- /dev/null +++ b/init.sh @@ -0,0 +1,2 @@ +# To install run: echo '@reboot //init.sh' | crontab -e +mkdir -p /tmp/downloads