Posts

    Day 701

    Deutsch

    selbsterklärend - self-explanatory.

    Bash - do something when a file appears in a directory

    Wrote this short shell script:

    #!/bin/bash
    if [[ $1 == "" ]] ; then
    	echo "Usage:"
    	echo "$0 whatever"
    	exit
    fi
    echo "Looking for filename"
    echo "$1"
    echo "at URI"
    URI="http://some.uri/path/$1"
    echo "$URI"
    
    while [[ true ]]
    do
    	RES="$(curl -I -s $URI | grep 200)"
    	if [[ $RES == "" ]] ; then
    		#echo "nothing changed"
    		:
    		# https://stackoverflow.com/questions/2421586/what-is-the-bash-equivalent-of-pythons-pass-statement
    	else
    		echo "$RES"
    		zenity --info --title="DING" --text="$1 finished!"
    		xdg-open $URI
    		exit
    	fi
    	sleep 5
    done
    

    Bash - python pass / do-nothing instruction

    What is the Bash equivalent of Python’s pass statement - Stack Overflow:

    • : 1
    • true is a command that successfully does nothing.

      (false would, in a way, be the opposite: it doesn’t do anything, but claims that a failure occurred.) … in other words, it does nothing, and fails at it.

    • In modern shells, :/true doesn’t matter unless you care about buildins.1

    Day 697

    Zsh prompt change based on dev/prod

    The script that sets dev/prod sets a variable to 1 if using dev. Based on that variable I get (or not) a red (B) in my zsh prompt.

    Did these changes to the theme clean2.zsh-theme:

    PROMPT='%{$fg[green]%}(%*/%!)$ZSH_USING_DEV%{$fg[$NCOLOR]%}%B%b%{$reset_color%}%{$fg[blue]%}%B%5c/%b%{$reset_color%} $(git_prompt_info)%(!.#.$) '
    
    ZSH_USING_DEV=""
    if [ "$USING_DEV" = "1" ] 
    	then
    		ZSH_USING_DEV="%{$fg_bold[red]%}[B]%{$fg[$NCOLOR]%}"
    	fi
    

    and in ~/.zsrhc

    alias uc='. ~/s/setenv.sh p'
    alias ud='. ~/s/setenv.sh d'
    

    zsh prompt export variables from a script

    Using the usual ./ way doesn’t work!

    Note the . ~/s.. in the script above. Running it as ~/what.sh will create a new shell, export the new values there, and close it. Starting with a . will make it run the script without starting a new shell. 1


    Day 696

    Confluence tabs + publishing

    “Publish without notifying watchers” exits.

    If I paste something from vim that has tabs in it in a Code block, in the Edit window it will look fine, but won’t at the end. Editing again will make it again look fine in the edit window. Moral: use spaces.

    vim tabs

    If you copypaste things from it to code blocks in jira/confluence it will start being weird. You can do expandtabs/retab to convert it to something that looks just like this with spaces when saved. Though feels suboptimal.


    Day 695

    Multiple monitors / productivity idea

    If I have a laptop and two external monitors, put the ‘distracting’ things on the laptop monitor and close the laptop. Open it when I’m officially doing a pause.

    My aliases for grep and history

    I shouldn’t forget that I have g aliased to grep, along with h to history | grep. Just tried this and it works:

    h vim | g http

    zsh expand all aliases; zsh keybindings; zsh show all files in directory

    Added this 1 to ./zshrc:

    expand-aliases() {
      unset 'functions[_expand-aliases]'
      functions[_expand-aliases]=$BUFFER
      (($+functions[_expand-aliases])) &&
        BUFFER=${functions[_expand-aliases]#$'\t'} &&
        CURSOR=$#BUFFER
    }
    
    zle -N expand-aliases
    bindkey '^E' expand-aliases
    

    ^E is <C-e>. Gets run anytime I use it, without connection to the written text. Neat.

    Also found this in ./.zshrc:

    # Usage:
    #   In the middle of the command line:
    #     (command being typed)<TAB>(resume typing)
    #
    #   At the beginning of the command line:
    #     <SPACE><TAB>
    #     <SPACE><SPACE><TAB>
    #
    # Notes:
    #   This does not affect other completions
    #   If you want 'cd ' or './' to be prepended, write in your .zshrc 'export TAB_LIST_FILES_PREFIX'
    #   I recommend to complement this with push-line-or edit (bindkey '^q' push-line-or-edit)
    function tab_list_files
    {
      if [[ $#BUFFER == 0 ]]; then
        BUFFER="ls "
        CURSOR=3
        zle list-choices
        zle backward-kill-word
      elif [[ $BUFFER =~ ^[[:space:]][[:space:]].*$ ]]; then
        BUFFER="./"
        CURSOR=2
        zle list-choices
        [ -z ${TAB_LIST_FILES_PREFIX+x} ] && { BUFFER="  "; CURSOR=2; }
      elif [[ $BUFFER =~ ^[[:space:]]*$ ]]; then
        BUFFER="cd "
        CURSOR=3
        zle list-choices
        [ -z ${TAB_LIST_FILES_PREFIX+x} ] && { BUFFER=" "; CURSOR=1; }
      else
        BUFFER_=$BUFFER
        CURSOR_=$CURSOR
        zle expand-or-complete || zle expand-or-complete || {
          BUFFER="ls "
          CURSOR=3
          zle list-choices
          BUFFER=$BUFFER_
          CURSOR=$CURSOR_
        }
      fi
    }
    
    zle -N tab_list_files
    bindkey '^I' tab_list_files
    

    <C-i> gives a list of files in the directory, and space-space-tab at the beginning of the line too. <C-q> (push-line-or-edit). More about it here: TIL: save half-typed commands in bash and zsh « Serge Gebhardt (sgeb.io) TL;DR remove command currently being edited and paste it at the next Return.


    Day 694

    German / English / slang

    Seen in the wild at work: ASAPST - like ASAP, but even more urgent. 1

    Linux multiple cameras/webcams

    Just found this hack: if the program you want to use doesn’t pick the right camera and you can’t control that through settings, open another program that will use the wrong camera - the first program will pick the first free camera, the one you want.


    Day 693

    Jira formatting

    Didn’t know that underline is marked +like this+. Why can’t we just agree on a flavour of markdown :(

    vim

    Changed my main dtb log file from using spaces to using tabs. 1

    :set tabstop=2      " To match the sample file
    :set noexpandtab    " Use tabs, not spaces
    :%retab!            " Retabulate the whole file
    

    Added set listchars=tab:\:\ to vimrc. NB space at the end.


    Day 689

    vim open multiple files via stdin

    When trying to do this: find | grep \/model | grep descr | xargs vim -p it opens all files in different tabs as wanted, but breaks the terminal afterwards (need to reset it).

    intellij idea tests “No tests found matching Method”

    Sometimes I see it and randomly restart and somehow it goes away, today it didn’t.

    The usual ‘Invalidate Caches & Restart’ didn’t fix it for me. BUT I had forgotten to annotate it as @Test.

    Other ideas about this from StackOverflow: 1

    • run the entire suite, not just that one test
    • If you rename the test it may use the last working running configuration that will fail

    Jira markup - indented bullet points / subpoints

    Uses asterisks, not indentation.

    * I am a bullet point
    ** I am related to the first one
    

    Day 687

    Intellij idea ‘for’

    Didn’t notice it before, but Idea shows the beginning condition of the loop when it’s outside the screen and cursor is on it’s closing braket.

    TODO vim

    Write something that: a) pastes multiline things automatically at the correct indentation b) copies URIs alone, without leading tabs/spaces. As a bonus - copies only the URI at a certain line without anything else. (I believe I can use kitty for this too, need to look into hints again)


    Day 686

    screen attach a screen that is ‘attached’ after connection drop

    The magic formula I used in the irssi days for all cases works here too: screen -raAd $n

    screen scrollback

    To change it during runtime, <C-A>:scrollback $number. Otherwise ~/screenrc:

    defscrollback 1000000
    

    nextcloud

    You can drag-n-drop files from the OS to a folder in nextcloud web gui, and it will automatically upload the file directly there (and inherit all permissions)


    Day 683

    Linux disable and reenable laptop keyboard

    xinput -list

    Note the id of “AT Translated Set 2 keyboard” (14 in my case), it’s the laptop keyboard, and of the one labeled “master keyboard” (3 in my case). xinput float $id and xinput float $id $id-master. 1

    xinput float 14         #disables laptop keyboard
    xinput reattach 14 3    #enables it back
    

    ssh keys (id_rsa, id_rsa.pub)

    Errors like:

    Permissions 0644 for '/home/me/.ssh/id_rsa' are too open.
    It is required that your private key files are NOT accessible by others.
    This private key will be ignored.
    

    can be fixed by setting the permissions to 400.

    Java complaining about --add_opens + $JAVACMD

    For some reason the script took java8 instead of the java11 returned by which java, through $JAVACMD. Temporarily fixed by doing JAVACMD="/usr/bin/java" ./the_script.sh.


    Day 682

    linux screen

    If you leave screen in copy mode and detach, it’ll be in copy mode when you attach it back and give the impression that no new output happened from the time you detached it.


    Day 681

    German ‘alle’ deklination, singular/plural

    Read more...

    Day 680

    German

    Read more...

    Day 675

    qutebrowser new profile and basedir

    Created a new basedir, where I symlinked the config.py from the original one: 11399 5.11.2020 09:54 ln -s ~/.config/qutebrowser/config.py ../profile2/config/config.py

    Read more...

    Day 674

    Slack / Electron apps hard restart

    <Ctrl-Shift-R> does a hard-restart that sometimes fixes issues with Electron apps such as Slack. (TS)

    Read more...

    Day 673

    Java / German

    Sehr schönes deutschsprächiges Buch über Java, dem ich nützen könnte, um mein IT-Wortschatz zu verbessern:

    Read more...

    Day 672

    diff side by side

    Read more...

    Day 668

    German

    Ctrl+C - “Steuerung-C” - Strg.

    Read more...

    Day 667

    vim TODO

    For my log, it would be interesting to create a keybinding that prepends current time to the beginning of the new created line and stays in insert mode.

    Read more...

    Day 665

    Confluence creating pages drafts

    Confluence saves draft version of the things you write if a page already exists. If the page is not created yet, no draft version is saved.

    Read more...


Subscribe