Skip to content

Instantly share code, notes, and snippets.

View firedynasty's full-sized avatar

StanT_ firedynasty

View GitHub Profile
function p() {
     if [[ $# -eq 0 ]]; then
        hello_var=$(cat /Users/username/desktop/macbook_pro_scripts/echo_files/count_open.txt)  
        second=$hello_var
        let second++
        echo -n $second > /Users/stanleytan/desktop/macbook_pro_scripts/echo_files/count_open.txt
        open "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$second | tail -1)"
        echo "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$second | tail -1)"
    else
@firedynasty
firedynasty / rclone_dropbox.md
Created August 27, 2021 02:14
rclone_dropbox
function dropbox () {
    if [[ $# -eq 0 ]]; then
        echo 'need parameter'
        echo 'dropbox_delete_screenshots_2'
    else
        rclone copy $@ dropbox:screenshots_macbook2
    fi 
@firedynasty
firedynasty / bash_multiple_files.md
Last active September 3, 2021 05:13
Bash to open multiple files
function opens(){
      if [[ $# -eq 0 ]]; then
      elif [[ $# -eq 1 ]]; then
        open "$(find . -type f -maxdepth 2 -not -path '*/\.*' | sort | head -$1 | tail -1)"
      else
        hello_var=$(echo -n "$1")
        minus_var=$(echo -n "$2")
        count_=0
function copy() {
    if [[ $# -eq 0 ]]; then
        echo 'first argument: file'
        echo 'second argument: line number'
    else
    sed -n $2p $1 | pbcopy 
    fi
}
@firedynasty
firedynasty / change_func.md
Last active September 8, 2021 18:28
Change and store directories that you have been
function cd_func () {
  local x2 the_new_dir adir index
  local -i cnt

  if [[ $1 ==  "--" ]]; then
    cat -n /Users/username/desktop/macbook_pro_scripts/echo_files/test_3.txt
    return 0
  fi
@firedynasty
firedynasty / browse.sh
Created October 13, 2021 16:51
opening links from clipboard (for browsing .txt file)
function browse() {
hello_var=$(echo -n `pbpaste`)
# set the clipboard to a variable
char=":"
# char in case there are multiple links
hello_var_2=$(awk -F"${char}" '{print NF-1}' <<< "${hello_var}")
# checking for mulitple https: links
if [ "$hello_var_2" -gt 1 ]; then
# if there are multiple links then return this statement
echo 'set str1'
@firedynasty
firedynasty / gist:0d58a95a358a33c45b229792f733c18d
Created October 22, 2021 04:17
delete all comments from a text file
function delete() {
echo "sed -i '' '/^#/d'"
echo "sed -i '' '/^$/d;G'"
}
in command line for mac:
$ sed -i '' '/^#/d' (yourfilename here)
@firedynasty
firedynasty / reading_through_files_like_a_book.bash
Created March 10, 2022 04:49
These commands in bash allow you to read through files like a book and you can go to a different placeholder
#going in and out of folders with CD resets the count
function cd() {
local x2 the_new_dir adir index
local -i cnt
@firedynasty
firedynasty / chang_file.bash
Created March 11, 2022 18:06
Updated change files in the folder with bash like reading a book
function 00(){
if [[ $# -eq 0 ]]; then
current_folder_count=$(cat /Users/stanleytan/Desktop/macbook_pro_scripts/echo_files/other_test.txt)
current_folder_count=$(($current_folder_count + 0))
#echo $current_folder_count
second_count=$(cat /Users/stanleytan/desktop/macbook_pro_scripts/echo_files/count_open.txt)
second_count=$((second_count+1))
echo -n $second_count > /Users/stanleytan/desktop/macbook_pro_scripts/echo_files/count_open.txt